Write image data as binary to append existing file 
Author Message
 Write image data as binary to append existing file
I would like to take the image in an existing picturebox
on a form and write the binary code for that image into a
data file for retrieval later.  I'm having trouble
figuring out how to write it out.

This is in VB.NET.

Any help or sample code would be great.

Thank you,

Mateo



Tue, 02 Aug 2005 04:25:56 GMT  
 Write image data as binary to append existing file
hey man!
yeah, it's no sweat...all you have to do is use the .Save
method of the system.drawing.image object...like this:

    Sub test()
        Dim pic As New PictureBox()
        Dim img As Image
        img = pic.Image
        Try
            img.Save("c:\img.jpg", _
                 Imaging.ImageFormat.Jpeg)
        Catch
            'image could not be encoded
        End Try
    End Sub

say that pic is the picturebox you are referencing.  all
you have to do is something like pic.Image.Save
(yourpath,yourformat), or just pic.Image.Save(yourpath),
depending on whether you wish to change the format or
not...you can do image compression conversions and stuff,
but that's the simplest way.  i WOULD have a try...catch
statement around the .Save tho, just in case you attempt
to save to a location that is read-only, or if you try to
save it on top of another file.

anyways, good luck, man!
ben

Quote:
>-----Original Message-----
>I would like to take the image in an existing picturebox
>on a form and write the binary code for that image into
a
>data file for retrieval later.  I'm having trouble
>figuring out how to write it out.

>This is in VB.NET.

>Any help or sample code would be great.

>Thank you,

>Mateo
>.



Tue, 02 Aug 2005 06:48:53 GMT  
 Write image data as binary to append existing file
Hi aguilanegra,

You can use the Image.Save Method (Stream,ImageFormat) method to save the
image to a stream, and then write/append the stream to a file. When you
want to retrieve the file, you can use the Bitmap class. It has a
constructor that accepts a stream. You can use this constructor to
construct the image from a stream.

Also, you can use the BinaryFormatter class to serialize and deserialize
image objects. For more information, please check this class in the MSDN.

Hope this helps.

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Quote:
>Content-Class: urn:content-classes:message


>Subject: Write image data as binary to append existing file
>Date: Thu, 13 Feb 2003 12:25:56 -0800
>Lines: 12

>MIME-Version: 1.0
>Content-Type: text/plain;
>    charset="iso-8859-1"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>Thread-Index: AcLTnh0dprPrnSXoTLez3/ZtynS2bw==
>Newsgroups: microsoft.public.dotnet.languages.vb
>NNTP-Posting-Host: TK2MSFTNGXA10 10.40.1.162
>Path: cpmsftngxa08!cpmsftngxa06
>Xref: cpmsftngxa08 microsoft.public.dotnet.languages.vb:90383
>X-Tomcat-NG: microsoft.public.dotnet.languages.vb

>I would like to take the image in an existing picturebox
>on a form and write the binary code for that image into a
>data file for retrieval later.  I'm having trouble
>figuring out how to write it out.

>This is in VB.NET.

>Any help or sample code would be great.

>Thank you,

>Mateo



Tue, 02 Aug 2005 10:27:34 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Write data in binary file / Convert Image

2. about Append the data into existing Excel File

3. Getting binary data for image and writing/reading it

4. Write binary data from SQL as image/bitmap in RTF

5. File I/O - writing/inserting data to existing file

6. Write ADO Field containing binary data (files) to the file system

7. Help Writing Image to Binary File

8. Reading/Writing Data for Binary Files

9. How to write binary data into a file?

10. Writing binary data to file with VBScript?

11. writing binary data to a file

12. How to append another word file into existing word file in VB

 

 
Powered by phpBB® Forum Software