Skip to main content
gamedev.net
🔒 Locked

2D Image Rotation Algorithm

Started by Carradine May 23, 2002 at 9:11 AM 1 replies 2.6k views
Original Post
Carradine
Carradine
I am looking for a basic image rotation algorthm in which I could rotate a set of 2D data by any angle. I want to accomplish this similar to the way Paint Shop Pro or Adobe Photoshop most likely does it. I attempt to do vector rotation on each point, but that does not give me an accurate conversion at all. Any help would be greatly appreciated. Carradine [edited by - Carradine on May 23, 2002 10:13:30 AM]
--------------------------Vantage: Greenlit on Steam / Independent Games Festival Submission http://www.crystaldragon.com
kill
kill
There are a lot of resources here on gamedev about it. You can also look on flipcode and of course on google. You''ll get a lot of details and some demo code by just looking around.

Just to get you started, if you rotate every single point separately your image will look ugly. The simplest way to rotate an image without any filtering is the following.
1. Rotate the four corners of the image with trig functions.
2. Use Bresenham''s line algorithm to find the edge points.
3. At this point you have the corners and the edges. Now pick two opposite edges and for every point on the edge draw a line using Bresenham''s algorithm.

I''m not sure if my explanation is of any help, in fact, now that I read it I don''t understand it myself but it should give you pointers for further research. Just type "Bresenham image rotation" in google and you should get enough hits to get you started.
Thr33d
Thr33d
Yep, look into what kill is talking about... I''m just (mainly) a vb coder, but I finally finished a simple little software renderer supporting texturemapping. The engine supported rotations on the objects and camera, and thus needed to draw a ''rotated image'' on a convex poly.

The method kill explained is refered to as scanline conversion, umm... hugo elias has a good amount of info oh his site (freespace.virgin.net/hugo.elias i think, if not, search for his name on google)

Anyway, he has some great tutorials explaining how to do what you want to do (in 3d, but could be easily used in 2d by just dropping the z from the equation)

Good luck,
-Michael

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.