Mail Archives: djgpp/1997/11/23/00:02:01
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 -