Hello
Assuming that you use a Steam that support seek operations (such as
FileStream) you can do the following
long startPos = bw.BaseStream.Position;
bw.Write((Uint64)0); // placeholder
bw.Write(type); // type can be string, byte array or char array
long imageStartPos = bw.BaseStream.Position;
img1.saveFile(bw.BaseStream, ...);
long endPos = bw.BaseStream.Position;
long imageSize = endPos - imageStartPos;
bw.BaseStream.Position = startPosition;
bw.Write(imageSize);
bw.BaseStream.Position = endPos;
if the Stream doesn't support seek operations, you can save the image to a
memory stream, get its size then write to the original stream.
Best regards,
Sherif
"Peder Y" <py*****@ec.auckland.ac.nz> wrote in message
news:10**************************@posting.google.c om...
Say I have several images, a jpg a gif and a bmp.
Now, I want to save these files to a single binary file.
I store the images in, say, Image img1, img2, img3;
1) How can I retrieve the size of an image in an Image object?
I have a BinaryWriter bw.
I plan to write to a stream writing TYPE (3 char def. like 'B''M''P'),
SIZE (UInt64), and IMAGEDATA.
2) Can I do this using img1.saveFile(bw.BaseStream, ...)?
Thanks!
- Peder -