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(b w.BaseStream, ...)?
Thanks!
- Peder - 2 2092
Hello
Assuming that you use a Steam that support seek operations (such as
FileStream) you can do the following
long startPos = bw.BaseStream.P osition;
bw.Write((Uint6 4)0); // placeholder
bw.Write(type); // type can be string, byte array or char array
long imageStartPos = bw.BaseStream.P osition;
img1.saveFile(b w.BaseStream, ...);
long endPos = bw.BaseStream.P osition;
long imageSize = endPos - imageStartPos;
bw.BaseStream.P osition = startPosition;
bw.Write(imageS ize);
bw.BaseStream.P osition = 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.auc kland.ac.nz> wrote in message
news:10******** *************** ***@posting.goo gle.com... 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(b w.BaseStream, ...)?
Thanks!
- Peder -
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.FromStrea m 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.NO SPAM> wrote in message news:<Ob******* ******@TK2MSFTN GP12.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.P osition; bw.Write((Uint6 4)0); // placeholder bw.Write(type); // type can be string, byte array or char array long imageStartPos = bw.BaseStream.P osition; img1.saveFile(b w.BaseStream, ...); long endPos = bw.BaseStream.P osition; long imageSize = endPos - imageStartPos; bw.BaseStream.P osition = startPosition; bw.Write(imageS ize); bw.BaseStream.P osition = 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.auc kland.ac.nz> wrote in message news:10******** *************** ***@posting.goo gle.com... 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(b w.BaseStream, ...)?
Thanks!
- Peder - This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 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'),
|
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 server. I know there are ways to go
and get a page, but this one would be dynamic and wouldn't be saved so I
would need to save it while it is still active or have it forwarded to an
asp.net page that will take the html code and save it to a file.
TIA...
|
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 control which inherits the panel
and added three panel control which host the 3 background images ( one to
the left the other to the right and one to fill the gap) now with this
control textboxes will be placed on these controls once they are added...
|
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:
An unhandled exception of type
'System.Runtime.InteropServices.ExternalException' occurred in
system.drawing.dll
Additional information: A generic error occurred in GDI+.
|
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 disable js in the browser ?
TIA
| |
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 writes the data from sys.stdin to
a file which is stat'ed by another script called asyncornously from
javascript. In the end I am able to make a progress bar for file uploads
via http.
Anyway, I have printed sys.stdin to a file and looked at it...
|
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 --> Save) in
MS Photo Editor, the file is automatically shrunk in size to 81 KB's.
When doing the same thing in MS Paint, the file is shrunk to 54 KB's.
The file has the same number of pixels after both saves (as expected).
My question follows...
|
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 to change the Content-
Type and Content-Disposition headers, and essentially print the same
report, and it's done. That works fine.
But in some reports on the web I need to show images. The web part is
fine, but I'm having a tough time...
|
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.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |