[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Rotozoom and mask errors



(I submitted this through the google group once, before realizing that
I had to register for my submissions to go through. It didn't show up,
so I read up, registered to the list, and am re-sending this. My
sincerest apologies if I end up sending the same message twice!)

I'm not sure if any of these have been brought up before, but I'm
wrestling with these issues in a project, and someone on the pygame
IRC mentioned that it may be a bug and recommended that I talk to you
guys.

Rotozoom issues:
I'm using rotozoom to handle rotation, and encountered the following
issues (in all cases, scale is 1):

Distortion on 0 rotation: When rotating to 0 degrees or a number not
divisible by 90/pi, the image has some weird kind of blurring. This is
understandable for non-orthogonal rotations, but for rotation to 0, it
makes very little sense. shouldn't 0 rotation, 1 scale not even touch
the image?
http://i.imgur.com/k2VRN.png
In this image, the bottom image is 0 rotation, the top is 180 degree
rotation. The image on the right is a copy of the source sprite that I
photoshopped in, for comparison. Zoom to 200x to better see the
blurring along the outline of the bottom left image.

Rotating oddly: When I rotate a POT texture, I get a strangely offset
result. This can be illustrated by a simple experiment with colorkeys:
http://i.imgur.com/haher.png
Notice that, in addition to the blurring at 0 degrees (which also
seems to screw up the colorkey, letting some red bleed in), the top
image (rotated 180 degrees) has some ugly black lines where the
rotated sprite didn't quite match up with the surface. My (naive)
guess is that rotozoom is halving the image dimensions and rotating
around the pixel at 64x64, whereas it should rotate around the point
at the center of the 4 center pixels (in this case, 64x64, 65x65,
64x65, 65x64, if I'm correct).
http://i.imgur.com/n0vXw.png
Here's another image to illustrate 90-degree rotations. the top image
is rotated 180 degrees, the bottom image is rotated 270 degrees.

Masks are really weird!: I'm trying to use the
pygame.sprite.collide_mask function with SpriteCollide for certain
types of collision, but it seems to really screw up whenever I try
using it with a rotozoom'd sprite.image. More on this as I figure out
more about the problem. Something that would help troubleshooting a
*lot* would be if I had a way of blitting a mask onto the screen, so
that I could see where collisions actually occur. Any help with that,
too, would be appreciated.

Thank you! I hope my descriptions were verbose enough, and I (very
eagerly) await your replies! :D