|
doubt about load_bitmap(const char *filename, RGB *pal) |
sj971059
Member #7,689
August 2006
|
I read from allegro manual, I found before a bitmap is loaded to the program,We'll by the way : after display the image to screen, I tried to get the bitmap color_depth, if we set 8 bits as the color_depth , the bitmap's color_depth is 8; here is the code : set_color_depth(8); if (set_gfx_mode(GFX_AUTODETECTED, w, h, 0, 0) != 0) { allegro_message("Unable to set mode %ix%i with 8bpp\n", w, h); } /* load the image */ background = load_bitmap(filename, pal); <------ here if (background != NULL) { set_palette(pal); <------ here }; another : set_color_depth(32); if (set_gfx_mode(GFX_AUTODETECTED, w, h, 0, 0) != 0) { allegro_message("Unable to set mode %ix%i with 32bpp\n", w, h); } /* load the image */ background = load_bitmap(filename, NULL); <----- here
|
BAF
Member #2,981
December 2002
|
8 bit is only 255 colors so for it to be right you need a pallette to tell it what colors are which. On higher bit modes, you have "nearly unlimited" colors, so pallettes arne't used. The color depth changes because when you load the bitmap, Allegro converts it to the current color depth automagically. |
Evert
Member #794
November 2000
|
Quote:
If we set 8 bits as the color_depth, when we use load_bitmap(filename, pal), the pal can't been passed as NULL , it must been a pointer points to a PALETTE type variable, after load_bitmap, we'll call set_palette(pal), if we doesn't do so,the last display reust is NOT right;
You're over complicating. You can always pass NULL for the pal argument, in which case the palette of the bitmap will be ignored (if there is one). Only 8 bit bitmaps have palettes anyway, so if you're loading a high or true colour image, the pal argument will be ignored anyway. Quote:
I tried to get the bitmap color_depth, if we set 8 bits as the color_depth , the bitmap's color_depth is 8; You're converting the colour depth to the current colourdepth when the file is loaded; see set_color_conversion(). |
|