delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/23/00:02:01

From: George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Some trouble with Allegro & DJGPP
Date: 22 Nov 1997 00:34:16 GMT
Organization: Oxford University, England
Lines: 38
Message-ID: <6559a8$ilq$5@news.ox.ac.uk>
References: <3475d323 DOT 781597 AT news DOT nuernberg DOT netsurf DOT de>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Fri, 21 Nov 1997 18:50:23 GMT in comp.os.msdos.djgpp Nighthawk <nighthawk DOT NOSPAM AT nuernberg DOT NOUCE DOT netsurf DOT de> wrote:

: I'm currently developing a module for Allegro to support the loading
: of GIF Files (yes, I know there is already one, but I need it for
: special purposes :) and I ran into some trouble when reading the
: palette. The program always crashes there.
: Here's the snippet of code that's concerned :

: if (GlobalPallete)
:      for (i = 0; i < ColorMapSize; i++) {
:           pallete[i]->r = NEXTBYTE;
:           pallete[i]->g = NEXTBYTE;
:           pallete[i]->b = NEXTBYTE;
:      }

: I have to say to this :
: The function is defined as BITMAP *load_gif(const char* name, PALLETE*
: pallete);

pallete is then a pointer to an array of RGBs.  You're using it above
as an array of pointers to RGBs.  What you should write is:

          (*pallete)[i].r = NEXTBYTE;

There's not much point in making pallete a PALLETE* anyway -- you
could just make it a PALLETE, or RGB *, and then use:

          pallete[i].r = NEXTBYTE;

This would be more consistent with the other Allegro load_*
functions.  You would then call your routine like this:

BITMAP *bmp;
PALETTE pal;
load_gif("file.gif",pal);

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


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