Mail Archives: djgpp/1997/08/23/10:21:05
Chris Frolik writes:
>Is there a fast and easy way to copy RLE sprites? If anyone has written
[...]
>I know this method of creating a bitmap is disgusting and slow. Is
>there a faster way to avoid the "middle-man" and just copy from one
>RLE_SPRITE to another?
There is, but it is also not very elegant. If you look at the definition
of the RLE_SPRITE structure in allegro.h you will see that it is:
typedef struct RLE_SPRITE /* a RLE compressed sprite */
{
int w, h; /* width and height in pixels */
int color_depth; /* color depth of the image */
int size; /* size of sprite data in bytes */
signed char dat[0]; /* RLE bitmap data */
} RLE_SPRITE;
Since it is just a single block of binary data, you can compute the size
as sizeof(RLE_SPRITE)+sprite->size. Then just malloc that much memory
for your new sprite, and memcpy() from the old image to the new...
But I have to ask, why do you need to copy these sprites? I find it very
hard to imagine why that would be useful...
--
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 -