SDL_rotozoom offset

Started by
5 comments, last by gumpy 18 years, 10 months ago
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
Advertisement
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.
Rob Loach [Website] [Projects] [Contact]
Ah thanks for that Rob

What about zooming a picture?
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].
Rob Loach [Website] [Projects] [Contact]
Ahh, thanks for that Rob,
What library has SDL_rotzoom?
Quote:Original post by Ekim_Gram
What library has SDL_rotzoom?


SDL_gfx
This space for rent.

This topic is closed to new replies.

Advertisement