2D Trig Rotation problems
I''m using the standard trig formulas for rotatation, but I''ve got some missing pixels in the rotated image. I think this is due to rounding causing pixels to be shifted. Does anyone know of a fix or workaround for this? Or is there a better way than using Trig Rotation? Any help would be appreciated.
Thanks in advance,
-Jey Kottalam
14 Year Old Computer Programmer
http://www.armageddongames.com
-Jey Kottalam14 Year Old Computer Programmerhttp://www.armageddongames.com
Try taking the destination, pixel by pixel, and compute the source pixel color - not the other way around (which is a more natrual way of thinking but can give sloppy results, missing pixels (especially if you''re scaling the image too)).
In other words, instead of doing this:
for each pixel in source bitmap {
Take pixel A from the source bitmap. Rotate it by angle X to find it''s destination pixel B. Plot a pixel at B with A''s color.}
Do this:
For each pixel in the destination area {
Take pixel B from the destination. Rotate it by angle -X to find the source pixel A, and plot A''s color onto B. }
Of course you''ll want to do alot of optimization on that, but its the general principle, and you can optinally scale the image alot easier that way.
Some alternative methods to trig rotation are to use pre-rotated images, use D3D to rotate the images as textures, or some cards have a blt capability that supposedly can rotate the image (though I havn''t seen one of those elusive cards yet, so you''d have to emulate it anyway). I''m sure openGL also has some kind of ability to rotate the bitmap, but I''m not familiar with it.
-ns-
In other words, instead of doing this:
for each pixel in source bitmap {
Take pixel A from the source bitmap. Rotate it by angle X to find it''s destination pixel B. Plot a pixel at B with A''s color.}
Do this:
For each pixel in the destination area {
Take pixel B from the destination. Rotate it by angle -X to find the source pixel A, and plot A''s color onto B. }
Of course you''ll want to do alot of optimization on that, but its the general principle, and you can optinally scale the image alot easier that way.
Some alternative methods to trig rotation are to use pre-rotated images, use D3D to rotate the images as textures, or some cards have a blt capability that supposedly can rotate the image (though I havn''t seen one of those elusive cards yet, so you''d have to emulate it anyway). I''m sure openGL also has some kind of ability to rotate the bitmap, but I''m not familiar with it.
-ns-
-ns-
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement