Board index » delphi » Saving several bitmaps plus infos to a file

Saving several bitmaps plus infos to a file

Here you go!

var Bitmap:TBitmap;
    Stream:TFileStream;
begin
  Bitmap:=TBitmap.Create;
  Bitmap.Width:=100;
  Bitmap.Height:=100;
  Stream:=TFileStream.Create('c:\asdf.dat',fmCreate);
  Bitmap.SaveToStream(Stream);
  Bitmap.SaveToStream(Stream);
  Bitmap.SaveToStream(Stream);
  Bitmap.SaveToStream(Stream);
  Bitmap.SaveToStream(Stream);
  Bitmap.SaveToStream(Stream);
  Bitmap.SaveToStream(Stream);
  Stream.free;

Quote
> 1) Several bitmaps
> 2) Some infos that explain how the bitmaps will be displayed and used
after
> reading them from file ( for example i need to store some coords ,
> transparence values etc.. )

 

Re:Saving several bitmaps plus infos to a file


Hi,
i need to save (and then read ) into a single file the following things :

1) Several bitmaps
2) Some infos that explain how the bitmaps will be displayed and used after
reading them from file ( for example i need to store some coords ,
transparence values etc.. )

What is the simplest and/or the best way ? : i think i have to use a
filestream but i never did a such thing before so if anyone has some tip or
little of code , i would be very grateful ..
Francesco

Re:Saving several bitmaps plus infos to a file


Hi,
i need to save (and then read ) into a single file the following things :

1) Several bitmaps
2) Some infos that explain how the bitmaps will be displayed and used after
reading them from file ( for example i need to store some coords ,
transparence values etc.. )

What is the simplest and/or the best way ? : i think i have to use a
filestream but i never did a such thing before so if anyone has some tip or
little of code , i would be very grateful ..
Francesco

Re:Saving several bitmaps plus infos to a file


Quote
<francescos...@tiscalinet.it> wrote in message

news:9806t6$m6k3@bornews.inprise.com...

Quote
> i need to save (and then read ) into a single file the following things :

> 1) Several bitmaps
> 2) Some infos that explain how the bitmaps will be displayed and used
after
> reading them from file ( for example i need to store some coords ,
> transparence values etc.. )

On this page under TFileStream there are two examples:
- Combine data files into a single file and later split them apart
- Combine JPGs into a single file, split and display

http://homepages.borland.com/efg2lab/Library/Delphi/IO/StreamIO.htm

So, what you want to do is just a combination of these two examples.

--
efg     e...@efg2.com     Earl F. Glynn, Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab
Mirror:  http://homepages.borland.com/efg2lab/Default.htm

Re:Saving several bitmaps plus infos to a file


EMF. You can also add comments.

Feng Yuan  ( for the GDI book to read, check www.fengyuan.com )

Re:Saving several bitmaps plus infos to a file


Thanx  Earl ,

 i'll give a look at your examples..

Re:Saving several bitmaps plus infos to a file


Bitmaps saved to a stream start out with a
BITMAPFILEHEADER record. It has a
bfSize member that indicates the actual size
oif the data.

Your best bet is to save each bitmap to the stream,
then seek back and read in the  BITMAPFILEHEADER,
and verify that the bfSize is correct.

Upon reading the file back in, your best bet is
to read a single bitmap into a temporary stream,
then laod it, as the code for many bitmap readers
may try to read the entire stream as a single bitmap.

For robustness, I certainly would not recommend
using metafiles to store successive bitmap images.

Joe
-
Cycling to cure cancer: http://homepages.borland.com/jkaster/tnt/

Other Threads