473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Saving several images to one file

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 -
Nov 16 '05 #1
2 2061
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 -

Nov 16 '05 #2
Hi!
Thanks! This is my current approach as well, but I haven't coded the
retrieve part yet so it remains to see if it works. My notch, though,
is that I'm not exactly sure what Image.Save/Image.SaveFile saves, and
wether it can be retrieved again from the same stream. One could guess
Image.FromFile uses the file extension to determine how to handle the
stream of bytes, but Image.FromStream cannot retrieve this kind of
information. My hope is thus that this function examines the possible
"header" constellations in the stream and determines its original
format from this. Otherwise, I might have a problem... :-)

- Peder -
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message news:<Ob*************@TK2MSFTNGP12.phx.gbl>...
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 -

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Peder Y | last post by:
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...
3
by: Clay Black | last post by:
I need to find a way to save an HTML page to the IIS server. What I need is to have a button that once it is clicked the current page being displayed is saved to a location on the local IIS...
21
by: Michael Turner | last post by:
Hi Guys I have several images that will be used over and over again on different forms in the same place, I have decided to create a control to save space/time in development, I have create a...
1
by: M Keeton | last post by:
I currently have a picture which is stored in a "System.Drawing.Image" variable and I want to save it as a bitmap file. I have tried 2 different approaches and both give me the following error: ...
16
by: Fred | last post by:
hi, is there some way to prevent(at least for not so advanced users) image saving on local disk; currently i use javascript which handles the right mouse button click, but all it takes is to...
4
by: ACB | last post by:
I am rewriting an existing PERL script I wrote several months ago. It is a script that is used as the action for a form containing several type="file" inputs. The script is run unbuffered and...
6
by: NutsAboutVB | last post by:
Hello, I am a .NET programmer and I have a JPEG image file (from digital camera) of about 109 KB's in size, when I open it and save it (without making any alterations at all, just going to File...
6
by: Eddie | last post by:
Hi all, I am displaying a number of reports, and giving the users an option to display them on the web or download them to Excel. If they want the Excel file, I just use the PHP header command...
10
by: Nathan Sokalski | last post by:
I am using ASP.NET 2.0, and need to know how to save and use an image that is stored in an SQL Server image datatype. How can I do this using ASP.NET? Thanks.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.