# Image Rotation Problems

This topic is 3347 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've recently tried rotating a alpha-transparent PNG but have run into a few snag and hope you guys can help. Basically, all I'm doing is going through every pixel in the source bitmap, rotating it, and placing it on the destination bitmap in the new position. The image rotates great but the images have gaps and holes. Is there a technique I should be using?

##### Share on other sites
Yes, you should loop through the destination pixels instead. For each one of them, find out where they come from in the original image, apply some interpolation if need be and then populate it. You'll get no ugly artifacts if you do it this way.

##### Share on other sites
Thanks for the quick reply! I have the formula to go from source to destination:
x' = x * cos(a) + y * sin(a) + cx
y' = y * cos(a) - x * sin(a) + cy

Is it a matter of just using the same formula in reverse, or is there a clever way to work out the source destination? I'm actually quite surprise there isn't something in GDI or GDI+ that does both alpha transparencies and rotation.

##### Share on other sites
Quote:
 Original post by ChrominiumThanks for the quick reply! I have the formula to go from source to destination:x' = x * cos(a) + y * sin(a) + cxy' = y * cos(a) - x * sin(a) + cy

The inverse of that transformation is

x = (x' - cx) * cos(a) - (y' - cy) * sin(a)
y = (y' - cy) * cos(a) + (x' - cx) * sin(a)

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633724
• Total Posts
3013555
×