Read/Write Strings and Images in a single file

104 views Asked by At

I'm trying to save into a single file String + Image + String + Image ... and then read it in the same order. The images are PNG! I managed to save the file so I'm more concerned about the reading part. Am I supposed to use a combination of BinaryRead/Writers and PngBitmapDecoders?

Although I am working on and WPF applicaton I found that most convenient for me is to use the WinForms'es Image.Save() method like so:

pictureBox.Image.Save(fs, Imaging.ImageFormat.Png);

After this line I tested to BinaryWrite a simple text and another image, and my Hex Reader says everything's O.K.

enter image description here

Now I need to figure out a way to read it. I tried System.Drawing.Image.FromStream() and PngBitmapDecoder() but they fail..

Any ideas? Thanks in advance!

0

There are 0 answers