Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Create sub bitmap

This thread is locked; no one can reply to it. rss feed Print
Create sub bitmap
On1gh1r1
Member #16,028
July 2015

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
Member #562
July 2000
avatar

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.)

__________________________________________________
Skoobalon Software
[ Lander! v2.5 ] [ Zonic the Hog v1.1 ] [ Raid 2 v1.0 ]

Edgar Reynaldo
Member #8,592
May 2007
avatar

On1gh1r1
Member #16,028
July 2015

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
Member #8,592
May 2007
avatar

Go to: