- Online Community Forums » Programming Questions » An example of using load_bitmap

This thread is locked; no one can reply to it. rss feed Print
An example of using load_bitmap
Member #22,686
March 2022

I downloaded allegro- and I am trying to load bmp file via load_bitmap():

1#include <allegro.h> 2#include <stdio.h> 3int main(void) 4{ 5 BITMAP* b = load_bitmap("/home/ibse/alexlogo.bmp", NULL); 6 return 0; 7}

but get Segmentation fault error. The backtrace is

1Program terminated with signal SIGSEGV, Segmentation fault. 2#0 0x00007f6b7472c204 in create_bitmap_ex (color_depth=8, width=128, height=128) at /home/ibse/Downloads/allegro- 31042 if (system_driver->create_bitmap) 4(gdb) bt 5#0 0x00007f6b7472c204 in create_bitmap_ex (color_depth=8, width=128, height=128) at /home/ibse/Downloads/allegro- 6#1 0x00007f6b7470a97b in load_bmp_pf (f=f@entry=0x55da0b8775a0, pal=0x7ffdb59aa5e0, pal@entry=0x0) at /home/ibse/Downloads/allegro- 7#2 0x00007f6b7470b58d in load_bmp (filename=<optimized out>, pal=0x0) at /home/ibse/Downloads/allegro- 8#3 0x00007f6b7474e241 in load_bitmap (filename=0x55da0b373bc2 "/home/ibse/alexlogo.bmp", pal=0x0) at /home/ibse/Downloads/allegro- 9#4 0x000055da0b365e96 in main () at /home/ibse/Downloads/allegro-

Could anyone provide me with an example of how to use this routine correctly?

Edgar Reynaldo
Major Reynaldo
May 2007

Mark Oates
Member #1,146
March 2001

You need to start with use allegro_init.

If you were using Allegro 5, you would use al_init. An,d because you are loading a PNG image you would need to al_init_image_addon().

Chris Katko
Member #1,881
January 2002

Please stop using Allegro 4. It was made for DOS games. Like 20 years ago. In 99.99999% of all cases, you can "emulate" the feel of DOS in a proper Windows/Linux/Mac application.

“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Go to: