Bitmap rotation2

In the post Bitmap rotation1 we saw a bitmap rotating but till leaking at the corners. This meant that the background was still not covered totally. Fooling around with the boundaries did the trick:

in the drawRotatedBitMap method: we have a double loop

for(  y = miny  ; y <  maxy ; y++ )
{
for(  x = minx  ; x <  maxx  ; x++ )
{

//drawing from destination to source

}}

I added the small idea of looking if the pixel to be drawn was in the rectangle of the bitmap or not (using two triangle methods), if not, draw the pixel from the background (using the hidden background layer).

This left the corners not drawn and this amounted to leaking:

This leaking was removed later during the rotation … but still not good!

So fiddling a bit with the limits solved the problem:

for(  y = miny – 1  ; y <=  maxy + 1  ; y++ )
{
for(  x = minx – 1  ; x <=  maxx + 1  ; x++ )
{

No the image rotates without leaving pixels:

the nds movie can be found here:
not leaking rotation, nds file

source files:
not leaking rotation, zip file

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: