Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » al_load_bitmap crash ?!

This thread is locked; no one can reply to it. rss feed Print
al_load_bitmap crash ?!
xantier
Member #12,521
January 2011

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

Matthew Leverton
Supreme Loser
January 1999
avatar

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
Member #12,521
January 2011

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
Member #476
June 2000
avatar

You forgot to check al_load_bitmap for failure.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

xantier
Member #12,521
January 2011

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

Matthew Leverton
Supreme Loser
January 1999
avatar

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
Member #12,521
January 2011

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

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

Go to: