Mail Archives: djgpp/2000/12/15/10:36:35
JB <jamesb_420 AT hotmail DOT com> wrote in message
news:3a39477a DOT 22177941 AT news DOT virgin DOT net...
> I am trying to load multiple bitmaps using allegro, but i can't get
> them all to load in the correct color because the pallete is only set
> for one.
> What can i do?
You can let Allegro do the conversion for you by running in a higher colour
depth
for instance
BITMAP * bitmap_list[N]; // a list of pointers
BITMAP * in_bmp;
PALETTE in_pal; // a complete palette of 256 RGBs
allegro_init();
set_color_depth(32);
set_gfx_mode( GFX_AUTODETECT ,640,480,0,0);
for(n=0;n<N;n++)
{
in_bmp=load_bitmap(file,&in_pal); // loads a bitmap and stores the
palette in in_pal
set_palette(in_pal); // sets the palette used
for conversion
w=in_bmp->w; h=in_bmp->h;
bitmap_list[n]=create_bitmap(w,h); // makes a bitmap in the current
color depth
blit (in_bmp,bitmap_list[n],0,0,0,0,w,h); // blit does the colour
conversion
destroy_bitmap(in_bmp); in_bmp=NULL; // you have finished with the 8
bit and can reuse the pointer
}
from here you can run your program with all the palettes simultaneously, or
you could reverse the process and blit each bitmap to an 8 bpp one which you
create with ..
out_bmp=create_bitmap_ex(8,w,h);
set_palette(out_pal);
blit(bitmap_list[n],out_bmp . . . etc.
...so you can save them to use in an 8 bit program. There are various ways
of reducing the colours used which include stippling and error diffusion.
blit will usually use a simple nearest colour matched through a table as Tom
described. Read the docs section Converting Between Color Formats.
- Raw text -