Mail Archives: djgpp/1999/07/13/15:27:35
All you have to do then is write to a file the width, height, and color
depth of the bitmap (this will only work if it's a memory bitmap though),
then the data: your code will look like this:
//open file
BITMAP *bmp; //The bmp you want to write.
pack_iputw(bmp->w,myfile);
pack_iputw(bmp->h,myfile);
pack_iputw(bmp->vtable->color_depth,myfile);
//you must use the allegro functions for that because for some reason it
can't work with data of over 64KB.
pack_fwrite(bmp->dat,bmp->w*bmp->h*((bmp->vtable->color_depth+7)/8),myfile);
//close file
destroy_bitmap(bmp);
the inverse can be done to read it:
//open file
int w=pack_igetw(myfile);
int h=pack_igetw(myfile);
int cdepth=pack_igetw(myfile);
bmp=create_bitmap_ex(cdepth,w,h);
pack_fread(bmp->dat,bmp->w*bmp->h*((bmp->vtable->color_depth+7)/8),myfile);
//Close file
And that's it !
At 02:13 AM 7/13/99 -0300, you wrote:
>
>I know about save_bitmap, but this is now want I want to do.
>
>I want to save it to a file by dumping memory
>
>
>
- Raw text -