[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: [pygame] keep-aspect scale



I never used the transform module but if it asks for x and y sizes of the
final image you just have to multiply x and y for the factor that you want
to scale. Just try this
scalefactorx = (framex - oldx)/oldx
scalefactory = (framey - oldy)/oldy

if scalefactorx < scalefactory then
 newx = oldx * saclefactorx
 newy = oldy * saclefactorx
else
 newx = oldx * saclefactory
 newy = oldy * saclefactory

image = pygame.transform.scale( image, (new_x,new_y) )

I don't know if i am right but i just wake up and I don't want to load
python to try this.

> Err... I must be stupid, but I don't really follow you...
>
> A simple, working code example someone?
>
> destRect = Rect( (0,0), (x,y) )
> imageRect = image.get_rect()
> ...what do I put here?...
> image = pygame.transform.scale( image, (new_x,new_y) )
>
> // Wigren
>
> > So
> > you have destRect=(w,h)
> > origImage=(wo,ho)
> >
> > lets take
> >
> > alphaw=w/w0
> > alphah=h/h0
> > alpha_worst=min(alphaw,alphah)
> >
> > and scale the original picture par factor alphaworst
> >
> > and center it
> >
> > Guillaume
> >
> >
> >
> >
> > On Tue, 17 Jul 2001, Per Wigren wrote:
> >
> > > Hi!
> > >
> > > A simple question:
> > > I have a Rect (inside of a frame) that can be of any
> size
> > > and I have another Rect (image) that also can be of any
> > > size. I want to scale the image to be as big as possible
> > > inside the frame while keeping aspectratio so it doesn't
> > > get too wide or too tall.
> > >
> > > Any tips?
> > >
> > > Regards
> > > Per Wigren
> > >
>
>
> ____________________________________
> pygame mailing list
> pygame-users@seul.org
> http://pygame.seul.org
>

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org