Is there any way to add multiple bitmaps together to make one bitmap?
I.e have them next to each other without having to draw the same thing twice.
[image][image clone][image clone 2] etc.
I am doing this just to make my life easier when drawing a bullet tracer.
]]>Create the large bitmap and blit the smaller ones onto it? Which version Allegro?
]]>Allegro 5, I have no idea how to do that :/
]]>you can make a function that return the bitmap combined...
ALLEGRO_BITMAP combineBitmaps(ALLEGRO_BITMAP *a, ALLEGRO_BITMAP *b) { ALLEGRO_BITMAP *bitmapCombined; // here the code to combine bitmaps as Arthur links suggests return bitmapCombined; }
]]>
i'm novice too, but it's easy to make a routine for this !
use the instruction putpixel(*bitmap,x,y) and getpixel(*bitmap,x,y) for example.
int addition_image(*BITMAP source, *BITMAP additional ,int color_transparence)
{ int longx=(additional->w) ; int longy=(additional->h) ; int x,y ;
for(x=0;x<longx;x++)
for(y=0;y<longy;y++)
if (getpixel(additional,x,y)!=color_transparence)
if (x<source->w && y<source->h)
putpixel(source,x,y)=getpixel(additional,x,y) ;
return 0;
}
i'm novice too, but it's easy to make a routine for this !
Good job, you re-implemented draw_sprite .
Is there any way to add multiple bitmaps together to make one bitmap?
What you should get from this thread is that there's no way easier than to draw them twice. I'd suggest not combining the two bitmaps into one bitmap, but just create a function that draws those bitmaps instead of copy-pasting the two draws all over the place:
void repeat_bitmap(ALLEGRO_BITMAP* bmp, float x, float y, size_t num_x, size_t num_y) { bool was_held = al_is_bitmap_drawing_held(); al_hold_bitmap_drawing(true); for(size_t ii = 0; ii < num_y; ii++) { for(size_t jj = 0; jj < num_x; jj++) { al_draw_bitmap(bmp, x + jj * al_get_bitmap_width(bmp), y + ii * al_get_bitmap_height(bmp), 0); } } if(!was_held) al_hold_bitmap_drawing(false); }
The hold bitmap stuff is to make it draw faster.
]]>