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

Re: [pygame] Problems with pygame.transform.rotate and pygame.transform.rotozoom



Kaweh Kazemi wrote:

> I've got problems with pygame.transform.rotate and
> pygame.transform.rotozoom. See the attached test program which will
> rotate/rotozoom an image (small and big version) 90 degrees (-90 degrees to
> be exact) and will result in a corrupt image (small image) or moved image
> (big image) (the corrupt image could be the result of the movement).

ok, i really got into the rotate code last night. with a bit of work i 
was able to find and fix the following problems with transform.rotate.

* the image size was being computed incorrectly, it was always off by a 
couple pixels.

* the pixels "outside" the source image area were being computed 
incorrectly, this meant border pixels were being added where they 
shouldn't and it was pulling pixels from outside the surface area (bad, 
bad).

* the resulting image was being shifted by about 2 pixels in each direction.


whew, that was pretty bad. these big fixes should make rotate a lot 
friendlier. unfortunately, after a long time tinkering, there is still 
one bug i could not find or get rid of. in some cases, the resulting 
image is "shifted" by one pixel along the original X axis. i cannot 
figure this out, i tried and tried to make it work :[
for example, if you rotate an image 90 degrees, the resulting image will 
be shifted one pixel down (with the bottom line chopped and a row of 
border colored pixels at the top)

if anyone feels up to the task, i'd be really glad if you could find and 
smash the problem. be sure to start with the latest code in CVS. the 
transform module isn't too big, and the "rotate" function is the second 
one. ( now's your chance to get your name in the readme :] )


as for the rotozoom function. this is using the SDL_rotozoom library. 
which apparantly needs a bit of fixing. perhaps i can try to retrofit 
some of my own rotate fixes into the rotozoom code.

anyways, check out the cvs code and give the rotations a try :]

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