R
Richard
Hello,
I have a multipage tiff file which I am trying to output to a web browser
using Response.BinaryWrite. I am taking the tiff file, then looping for
each page and saving it off to a jpg in a memory stream. The problem I'm
having is when the page comes up, only the first image is shown. If I save
each page off in a file I can see that each page is unique and it's not a
problem with the stream, it seems to be a problem with outputting to the
browser. And my loop is running through for each page. My code is below,
any tips would be greatly appreciated. Thanks!
for (int i=0; i< tifPageCount; i++)
{
System.IO.MemoryStream JPGStream = new MemoryStream();
JPGStream.SetLength(0);
TifImage.SelectActiveFrame(new
System.Drawing.Imaging.FrameDimension(TifImage.FrameDimensionsList[0]), i);
TifImage.Save(JPGStream, System.Drawing.Imaging.ImageFormat.Jpeg);
JPGStream.Position = 0;
byte[] NewBuffer = new byte[JPGStream.Length];
JPGStream.Read(NewBuffer, 0, (int) JPGStream.Length);
JPGStream.Close();
Response.ContentType = "image/jpeg";
Response.OutputStream.Write(NewBuffer, 0, NewBuffer.Length);
Response.ContentType = "text/html";
Response.Write("<BR><BR><BR>");
}
Response.End();
TifImage.Dispose();
I have a multipage tiff file which I am trying to output to a web browser
using Response.BinaryWrite. I am taking the tiff file, then looping for
each page and saving it off to a jpg in a memory stream. The problem I'm
having is when the page comes up, only the first image is shown. If I save
each page off in a file I can see that each page is unique and it's not a
problem with the stream, it seems to be a problem with outputting to the
browser. And my loop is running through for each page. My code is below,
any tips would be greatly appreciated. Thanks!
for (int i=0; i< tifPageCount; i++)
{
System.IO.MemoryStream JPGStream = new MemoryStream();
JPGStream.SetLength(0);
TifImage.SelectActiveFrame(new
System.Drawing.Imaging.FrameDimension(TifImage.FrameDimensionsList[0]), i);
TifImage.Save(JPGStream, System.Drawing.Imaging.ImageFormat.Jpeg);
JPGStream.Position = 0;
byte[] NewBuffer = new byte[JPGStream.Length];
JPGStream.Read(NewBuffer, 0, (int) JPGStream.Length);
JPGStream.Close();
Response.ContentType = "image/jpeg";
Response.OutputStream.Write(NewBuffer, 0, NewBuffer.Length);
Response.ContentType = "text/html";
Response.Write("<BR><BR><BR>");
}
Response.End();
TifImage.Dispose();