SDL_rotozoom offset
When you rotate an image or scale an image with SDL_rotozoom, the center of the new image is slightly off (to the right and below slightly)
To illustrate:
http://vicious.sixlabs.org/normal.bmp (regular)
http://vicious.sixlabs.org/45.bmp (rotated 45 degrees)
The red dot is the center of the image
Is there a function that finds the offset of the img (both rotating and zooming the picture), ie, moves the rotated image to the left and upwards so the red dot is at the same location as the red dot is at http://vicious.sixlabs.org/normal.bmp
Thanks in advance
No, the rotation is correct. The problem is that when you rotate it, the size gets bigger according to the rotation. If you rotate a perfect square, it'll turn into a diamond with a larger respective width and height. To fix the problem, instead of drawing at (x, y) draw at (x-width/2, y-height/2). You'll find that it will then draw at the center point of x and y. This is the solution I took when working on Blastoids.
Same idea. If you draw it at x-width/2 and y-height/2 then it'll draw the surface centered on what point you give it [smile].
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement