[AD] Problem loading 32bit bmp file

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


The following code doesn't show the image being loaded. The screen
is just black. Other tools like gimp or display can view the image
correctly. Unix' file command says the image is PC bitmap data,
Windows 3.x format, 638 x 478 x 32. You can get this image from:

  http://gradha.sdf-eu.org/test.bmp (1.2 MB)

Here's the code I'm using:

#include <allegro.h>

    int main(void)
    {
        BITMAP *bmp;
        
        allegro_init();
        set_color_depth(32);
        if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0)) {
            allegro_message("Bah\n");
            return 1;
        }
    
        bmp = load_bitmap("test.bmp", NULL);
        if (!bmp) {
            set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
            allegro_message("No bmp!\n");
            return 2;
        }
    
        blit(bmp, screen, 0, 0, 0, 0,
            MIN(bmp->w, SCREEN_W), MIN(bmp->h, SCREEN_H));
        install_keyboard();
        readkey();
        destroy_bitmap(bmp);
        return 0;
    }

An initial gdb stepping through Allegro's code shows
that load_bmp_pf() sets bpp to 8 because there's no if
(infoheader.biBitCount == 32) and biCompression is 0.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/