Mail Archives: djgpp/1997/09/03/17:37:11
Mike Coulson writes:
> At the start of the Allegro example program number 18, the
>following lines appear:
>
>
> PALLETE my_pallete;
> BITMAP *scr_buffer;
>
>Can someone tell me why the BITMAP has to be a pointer to the buffer
>scr_buffer, whereas my_pallete is not a pointer?
The palette is in fact an array of RGB structures, so it will be passed
as a pointer to the bitmap loading function (C passes all array
parameters as the address of the array, which is the same thing as a
regular pointer). The difference is that the palette is a simple table
with a fixed size of 256 entries, so it can most easily be allocated by
the caller and later filled by the load routine, wheras a bitmap is a
much more complicated structure of variable size (depending on how large
the image in the file is), so the memory has to be allocated by the
loading function and then returned to the caller as a pointer.
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -