VintaSoft Annotation .NET Plug-in Discussions

Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.

Board index < VintaSoft Imaging < VintaSoft Annotation .NET Plug-in Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

Memorystream looks like empty



Memorystream looks like empty

Post by Junhui »

Hello, I have a question for this issue...

I opened image file on AnnotationViewer and draw some annotations, and saved that.
Saving to image, it works. But saving to memorystream, it doesn't work.
Here are codes below...
private void btnSave_Click(object sender, EventArgs e)
{
   MemoryStream mstream = new MemoryStream();
   JpegEncoder encoder = new JpegEncoder();

   annotationViewer1.Image.SaveAnnotations = true;
   annotationViewer1.Image.Save(mstream, encoder);
   annotationViewer1.Image.Save(@"C:\TEST\tmpImg.jpg", encoder);

   FileStream fstream = new FileStream(@"C:\TEST\tmpImg.jpg", FileMode.Open);
   StreamReader sr = new StreamReader(fstream);
   string tmpImg = sr.ReadToEnd();

   StreamReader sr2 = new StreamReader(mstream);
   string tmpImg2 = sr2.ReadToEnd();
            
   //save annotationed image to DB
   SavePictChart(tmpImg);
}
At sr(streamreader which reads saved file), tmpImg is not null, but at sr2(streamreader which reads memorystream), it doesn't have value.
I have to insert image with querystring to sybase database, so I need Memorystream.
Thank you for your reading., FileMode


Re: Memorystream looks like empty

Post by Alex »

Hello,

You need to move the position in the memory stream to the beginning of the stream before reading data from the stream:
mstream.Position = 0;
StreamReader sr2 = new StreamReader(mstream);
string tmpImg2 = sr2.ReadToEnd();
Best regards, Alexander


Re: Memorystream looks like empty

Post by Junhui »

It works well, thank you for your advice.


Page 1 from 1: 1