473,396 Members | 1,725 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,396 software developers and data experts.

Saving Images to Files (& Related Questions)

I'm relatively new to using FileStreams, so bear with me.

I'm trying to use the following code

Dim MapGraphicsFileStream As New System.IO.FileStream(MapGraphicsFile,
System.IO.FileMode.Create)
Dim MapGraphicsFileStreamWriter As New System.IO.BinaryWriter
(MapGraphicsFileStream)
Dim A As Integer
For A = 0 To MapGraphics.GetUpperBound(0)
MapGraphics(A).MapBitmap.Save(MapGraphicsFileStrea m,
System.Drawing.Imaging.ImageFormat.Bmp)
MapGraphicsFileStreamWriter.Write(MapGraphics
(A).DefaultProperties.Role)
Next
MapGraphicsFileStream.Close()
MapGraphicsFileStreamWriter.Close()
End

to write a series of System.Drawing.Images and associated properties
(currently one integer, but eventually far more extensive) to a datafile.

I read it during the next program session using a procedure that I judge
to be a rough inverse of the routine I use to write the data.

Dim MapGraphicsFileStream As New System.IO.FileStream(MapGraphicsFile,
System.IO.FileMode.Open)
Dim MapGraphicsFileStreamReader As New System.IO.BinaryReader
(MapGraphicsFileStream)
Dim A As Integer
For A = 0 To 1
MapGraphics(A) = New MapGraphicsTemplate
MapGraphics(A).MapBitmap = System.Drawing.Image.FromStream
(MapGraphicsFileStream)
MapGraphics(A).DefaultProperties.Role =
MapGraphicsFileStreamReader.ReadInt32
Next
MapGraphicsFileStream.Close()
MapGraphicsFileStreamReader.Close()

Only it doesn't work... while MapGraphic(A).DefaultProperties.Role seems
to write/read correctly across program sessions, both images read as
slightly corrupted versions of the image I selected for MapGraphic
(1).MapBitmap

Can anybody give me a simply-worded (since I am a FileStream beginner!)
explanation of where I went wrong and whereabouts the correct track might
lie?

Further, you'll notice that while For A = 0 To MapGraphics.GetUpperBound
(0) gets the number of iterations necessary to *write* all populated data
in the MapGraphics array, I have no equivalent for the reader.

My thanks for any help you can provide.
Feb 17 '06 #1
0 845

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

Similar topics

4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
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...
3
by: Dennis | last post by:
How can I save then retrieve an image from an access Database using VB.Net? -- Dennis in Houston
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: ...
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
0
by: connectrajesh | last post by:
INTERVIEWINFO.NET http://www.interviewinfo.net FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES NO ADVERTISEMENT
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...
4
by: cronusf | last post by:
Hello, I have a program that renders an animation. I would like the program to be able to save this animation to a popular video file. Is there a .NET API for doing this? I looked into...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...

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.