Image Generation.

  • Thread starter sarran rangarajan
  • Start date
S

sarran rangarajan

Hi,
i have collection of memorystream. I need to write (generate) an image
based on data that is present in all memorystreams.


string p = string.Format(@"C:\temp\{0}-Page.gif", messageId);
FileStream fs = new FileStream(p, FileMode.Append);
foreach (MemoryStream ms in m_streams)
{
byte[] image = ms.ToArray();
fs.Write(image, 0, image.Length);
ms.Position = 0;
}

I have 3 memory streams, but my image has only the first stream
contents.
 
P

Peter Duniho

i have collection of memorystream. I need to write (generate) an image
based on data that is present in all memorystreams.
[...]

What exactly is it that you expect or want to happen?

The code you posted should in fact be writing all three memory streams to
the output file. It most likely does, and you can confirm this fact by
looking at the length of the file (noting of course that you didn't post
any code that closes or disposes the FileStream object so there's a
possibility that the data at the very end of the file never gets written,
depending on what else your application is doing...since the code sample
is obviously not complete, it's not possible to say for sure what other
problems may exist).

But how is some application supposed to interpret such a file? The image
header isn't going to refer to the second two sections of data, so unless
you write custom code yourself to read each section all you are likely to
ever see is the first image in the file.

Assuming you have three MemoryStreams, each of which represents a single
image, how do you want those images to be combined? Are you expecting a
multi-part animated GIF? Or are you expecting a single image that is
somehow a combination of all three images? Or something else altogether?

Without knowing what exactly it is you want, it's not really possible to
offer any advice as to how to achieve that.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top