Sign in to follow this  
Zeophlite

SDL_rotozoom offset

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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].

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this