Create sub bitmap
On1gh1r1

I need to create a sub bitmap from an existing bitmap, so i looked for it into allegro manual and i found al_create_sub_bitmap() function, but, as i have understood, that function just cut the parent image, 'cause they share the same drawing memory. So, it's my misunderstanding or to create a sub bitmap i must do this way:

ALLEGRO_BITMAP *new_bitmap = al_create_bitmap(w, h);
al_set_target_bitmap(new_bitmap);
al_draw_bitmap_region(old_bitmap, x, y, w, h, 0, 0, 0);

StevenVI
On1gh1r1 said:

I need to create a sub bitmap from an existing bitmap

How do you define "sub bitmap"? If you mean you want to draw it onto another bitmap, then it looks like you're on the right track.

(I'm rather clueless on Allegro 5's API, so I can't comment on specifics at the moment.)

Edgar Reynaldo

What do you want to do with your 'sub' image? What is it for?

On1gh1r1

Sry, my wrong. I need to create some new ALLEGRO_BITMAP variables that are a region of an existing ALLEGRO_BITMAP, but that also are independent from him.
Ps: i don't want to use al_draw_bitmap_region(), but al_draw_bitmap(), so i need sub-bitmap =)

Edgar Reynaldo

Well, you have two choices. Clone the area, or create a sub bitmap. If you don't want the memory shared, clone the regions you want. If you don't mind if its shared, use a sub bitmap.

Thread #615608. Printed from Allegro.cc