al_load_bitmap crash ?!
xantier

i also included allegro_image.h and lib but al_load_bitmap("asd.bmp"); crashes. the image file is in the same directory.. No problem at loading but when i try to draw the bitmap, it crashes :/

Edgar Reynaldo

Did you call al_init_image_addon first?

Also, how are you drawing the bitmap?

Matthew Leverton

al_load_bitmap() must have returned null due to either not calling al_init_image_addon() or the program not running in the directory you think it is.

xantier

okay one more question

ALLEGRO_BITMAP *tempo;
tempo=al_load_bitmap(filename);

for (int i=0;i<Imgn;i++)
{
Image.push_back(al_create_sub_bitmap(tempo,(i*Imgw),0,Imgw,Imgh));
}

al_destroy_bitmap(tempo);

this code gives assertion (void*)0 error.

Thomas Fjellstrom

You forgot to check al_load_bitmap for failure.

xantier

when i remove destroy code, it works correctly. so how to remove temporary bitmap ?

Matthew Leverton

From the manual:

Quote:

Note that destroying parents of sub-bitmaps will not destroy the sub-bitmaps; instead the sub-bitmaps become invalid and should no longer be used.

Don't destroy the parent bitmap before you are done with the sub-bitmaps.

xantier

uhh then i will define another vector that contains images..

or current vector's first element will be main image for animated images

Thread #606226. Printed from Allegro.cc