Bitmap Rotation (i have checked other posts) - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Bitmap Rotation (i have checked other posts)

I had a look through all the examples, and i read many previous posts on the matter, but one thing seems to elude me.
I want the bitmap to rotate around its centre (or atleast appear to be doing so). Ive been playing around with the formulas and i cant seem to get it right.

for(source_y=pic_start_y;source_y>=pic_end_y;source_y++)
{
for(source_x=pic_start_x;source_x>=pic_end_x;source_x++)
{
new_x=(source_x*cos_angle+source_y*sin_angle)+new_origin_x;
new_y=(source_y*cos_angle-source_x*sin_angle)+new_origin_y;
if( (new_x > 0)
&&(new_x < ScreenX)
&&(new_y > 0)
&&(new_y < ScreenY) )
{
Pixel = PixelGet(source_screen, source_x, source_y);
PixelPut(new_screen, new_x, new_y, Pixel);
PixelPut(new_screen, new_x+1, new_y+1, Pixel);
}
}
}

The idea i have is to have a "screen" which holds various images. I take segments of that screen and reprint them onto a regularly updated screen, this way any errors are not cumulative. To solve the gaps in the image problem i just print the image twice with the second 1 pixel down and 1 pixel across from the first, this keeps it looking nice.

However when i change the angle, the image just creates rings on the screen, it is rotated correctly, i just need it to be repositioned accurately.

Any help is appreciated :)

Vusak
Sign In or Register to comment.