www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/12/15/10:36:35

From: "Matthew Smith" <matt AT the-good-stuff DOT freeserve DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Loading multiple bitmaps in allegro?
Date: Fri, 15 Dec 2000 15:25:25 -0000
Organization: Customer of Energis Squared
Lines: 48
Message-ID: <91dd6p$5dj$1@news7.svr.pol.co.uk>
References: <3a39477a DOT 22177941 AT news DOT virgin DOT net>
NNTP-Posting-Host: modem-153.lithium.dialup.pol.co.uk
X-Trace: news7.svr.pol.co.uk 976893977 5555 62.136.2.153 (15 Dec 2000 15:26:17 GMT)
NNTP-Posting-Date: 15 Dec 2000 15:26:17 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019