delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/13/15:27:35

From: varobert AT colba DOT net
Message-Id: <3.0.32.19990713152634.007ac310@mail.colba.net>
X-Sender: varobert AT mail DOT colba DOT net
X-Mailer: Windows Eudora Pro Version 3.0 (32)
Date: Tue, 13 Jul 1999 15:26:38 -0400
To: djgpp AT delorie DOT com
Subject: Re: About BITMAP structure ( ALLEGRO )
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

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 -


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