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

RE: [pygame] Possible problem in transform




>> Mike Benfield wrote:
>> rotate and rotozoom are destructive operations
>> they're not supposed to keep all the information.
>> I just keep the original image on hand and then
>> always rotate from that.

> Pete Shinners wrote:
> yes, this is the problem with rotate, it is 
> destructive. it's like scaling an image down, 
> you can't get the original back. if you do want 
> animated rotations, it's best to always keep a 
> copy of the original and rotate from that.

I'm doing the exact same thing in my example.

>> Mike Benfield wrote:
>> hopefully this is actually what your problem is.

No, it is not; it is a little more destructive :-)

> Pete Shinners wrote:
> each time you rotate, there will be some amount
> of 'error'. by rotating the same image multiple
> times, the image will get worse each time.

I can accept some bits in "strange" places due to the algorithm, but the rotate and rotozoom routines seem to mess up the bitmap a little more.

From a 16x16 image, the transform.rotate(img, 180) seems to create a 180 degrees rotated image. So far so good, but it is dispositioned 1 pixel down and 1 pixel to the right. From the origin it now seems a 17x17 image. transform.rotate then seems to copy back a 16x16 image, which across row 0 and across column 1 has a undefined or default green color (in my example). The transform.rotozoom might actually increase the size (didn't print the resulting size yet) to 17x17.

I've not looked at the code, but when transform.rotate uses transform.rotozoom it does make a bit sense.

I think my example is clearer than my above description...

http://fvw.freezope.org/GamePy/showPossibleError.zip

> Pete Shinners wrote:
> this is true with any rotating algorithm (afaik).
> even in photoshop if you rotate an image, then 
> rotate it back, the quality won't be the same 
> as the original. photoshop rotates are probably
> higher quality and are therefore less-lossy than
> pygame's rotate. (the rotozoom function is 
> antialiased, which should be pretty close?)

No problems with that, actually my example doesn't seem (visual inspection only) to be troubled by the algorithm, it is the loss of whole band(s) of pixels that troubles me...

Frank
(using PyGame 1.3 on Windows Me)
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org