I have a problem rotating a bitmap.
datafile[4]'s resolution is 200x320 and datafile[2] is 320x200. If rotate is 0, datafile[2] shows up great.
If rotate is 1, I get mostly garbage on the screen... what am I doing wrong to rotate the bitmap?
This is the code:
---
allegro_init();
set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0);
set_color_conversion(COLORCONV_TOTAL);
datafile = load_datafile("test.dat");
if(rotate) {
set_palette(datafile[4].dat);
bitmap = create_bitmap(200,320);
temp = create_bitmap(200,320);
blit(datafile[3].dat, bitmap, 0, 0, 0, 0, 200, 320);
rotate_sprite(temp, bitmap, 0, 0, itofix(64));
blit(temp, screen, 0, 0, 0, 0, 320, 200);
} else {
set_palette(datafile[2].dat);
bitmap = create_bitmap(320,200);
temp = create_bitmap(320,200);
blit(datafile[1].dat, bitmap, 0, 0, 0, 0, 320, 200);
blit(bitmap, screen, 0, 0, 0, 0, 320, 200);
}
-------
Thanks!!!
First off, don't forget about the code tags.
... temp = create_bitmap(200,320); blit(datafile[3].dat, bitmap, 0, 0, 0, 0, 200, 320); rotate_sprite(temp, bitmap, 0, 0, itofix(64)); blit(temp, screen, 0, 0, 0, 0, 320, 200); //you created temp with 200x300... why change that to 320x200 here? ...
It may be safer, but bulkier, to use this from now on:
blit(temp,screen,0,0,0,0,temp->w,temp->h);
[edit]
Of course, a common mistake. The "sprite" functions are a little diffrent from the "blit" functions in that the source and dest BITMAP*s are reversed in order.
rotate_sprite(temp, bitmap, 0, 0, itofix(64)); //should be rotate_sprite(bitmap, temp, 0, 0, itofix(64));
Usually, when you see that chaotic ugliness as bitmaps, it means nothing has been drawn to them yet. They either need to be cleared or drawn over.