Multipage Tif viewer

  • Thread starter Thread starter SF
  • Start date Start date
S

SF

Folks,

I've been running into problems with a multipage Tif viewer that I wrote to
display fax images in an ASP.Net app. I've been basically following the
standard examples on how to do this:

- Read the image from a file
- set the current frame
- write the frame data to an output stream

and ended up with this code:

<snip>
System.Drawing.Image b;
System.Drawing.Imaging.FrameDimension frameDim;

//Read Tif from file (todo: change fromFile to stream)
strFilename = ConfigurationSettings.AppSettings["Images.Dir"] +
Request["filename"];
b = System.Drawing.Image.FromFile(strFilename);

//Set current frame
frameDim = new
System.Drawing.Imaging.FrameDimension(b.FrameDimensionsList[0]);
int intFrame = int.Parse(Request["frame"]);
b.SelectActiveFrame(frameDim,intFrame);

//Save to output stream in jpg format
Response.ContentType="image/jpeg";
b.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
b.Dispose();
</snip>

Now, this code works fine with Group 4 Tiff files. However, I am dealing
with Group 3 and here the application throws a "A generic error occurred in
GDI+."-exception whenever intFrame>0 (basically I can view the first page
and that's it). I saw other people in newsgroups having the same kind of
roblem but it never got resolved. Is this a bug in System.Drawing.Image? Is
there a patch or workaround for this?

Any advice/suggestions/code samples greatly appreciated.
Thanks
-Stefan

PS: If needed, I can supply an example Tif for both Group3/Group4 formats.
 
I've been running into problems with a multipage Tif viewer that I wrote
to
display fax images in an ASP.Net app. I've been basically following the
standard examples on how to do this: ~snip~


Any advice/suggestions/code samples greatly appreciated.
Thanks


I would suggest that you consider using another technique that a friend of
mine uses when confronted with exactly the same issue. Whenever he runs into
this type of problem he locks himself in a closet and screams. Then he comes
out and still has the problem but at least he feels better.
Once you do that just change your code and your algorythim and all should
work nicely.
 
Hello Stefan,

Thanks for posting in the group.

After reviewing the problem description carefully, I think the exception should happen at line:
b.SelectActiveFrame(frameDim,intFrame);
If you transfer a >0 paramter to intFrame, the exception happens, right?

If so, it is related to GDI+ issue, not asp.net. I think you could create a simple windows form application and paste the same
code to see whether you could repro the problem or not. My suggestion for you is to post this question in framework.drawing
group. The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and
other partners who the newsgroups regularly can either share their knowledge or learn from your interaction with us.

When posting, it is better if you provide the following informatin:
1) Which OS? If windoes XP, please install windows XP SP1 first.
2) Which version of .NET framework are you using?
3) Could you use fax viewer to view all the pages of that TIff file successfully?

Thanks.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "SF" <[email protected]>
!Subject: Multipage Tif viewer
!Date: Thu, 14 Aug 2003 13:09:19 -0700
!Lines: 49
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: mx1.captaris.com 12.129.11.151
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:168051
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!Folks,
!
!I've been running into problems with a multipage Tif viewer that I wrote to
!display fax images in an ASP.Net app. I've been basically following the
!standard examples on how to do this:
!
!- Read the image from a file
!- set the current frame
!- write the frame data to an output stream
!
! and ended up with this code:
!
!<snip>
! System.Drawing.Image b;
! System.Drawing.Imaging.FrameDimension frameDim;
!
! //Read Tif from file (todo: change fromFile to stream)
! strFilename = ConfigurationSettings.AppSettings["Images.Dir"] +
!Request["filename"];
! b = System.Drawing.Image.FromFile(strFilename);
!
! //Set current frame
! frameDim = new
!System.Drawing.Imaging.FrameDimension(b.FrameDimensionsList[0]);
! int intFrame = int.Parse(Request["frame"]);
! b.SelectActiveFrame(frameDim,intFrame);
!
! //Save to output stream in jpg format
! Response.ContentType="image/jpeg";
! b.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
! b.Dispose();
!</snip>
!
!Now, this code works fine with Group 4 Tiff files. However, I am dealing
!with Group 3 and here the application throws a "A generic error occurred in
!GDI+."-exception whenever intFrame>0 (basically I can view the first page
!and that's it). I saw other people in newsgroups having the same kind of
!roblem but it never got resolved. Is this a bug in System.Drawing.Image? Is
!there a patch or workaround for this?
!
!Any advice/suggestions/code samples greatly appreciated.
!Thanks
!-Stefan
!
!PS: If needed, I can supply an example Tif for both Group3/Group4 formats.
!
!
!
!
!
 
Thanks, Yanhong, you nailed it!

Yan-Hong Huang said:
Hello Stefan,

Thanks for posting in the group.

After reviewing the problem description carefully, I think the exception should happen at line:
b.SelectActiveFrame(frameDim,intFrame);
If you transfer a >0 paramter to intFrame, the exception happens, right?

If so, it is related to GDI+ issue, not asp.net. I think you could create
a simple windows form application and paste the same
code to see whether you could repro the problem or not. My suggestion for
you is to post this question in framework.drawing
group. The reason why we recommend posting appropriately is you will get
the most qualified pool of respondents, and
other partners who the newsgroups regularly can either share their
knowledge or learn from your interaction with us.
When posting, it is better if you provide the following informatin:
1) Which OS? If windoes XP, please install windows XP SP1 first.
2) Which version of .NET framework are you using?
3) Could you use fax viewer to view all the pages of that TIff file successfully?

Thanks.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "SF" <[email protected]>
!Subject: Multipage Tif viewer
!Date: Thu, 14 Aug 2003 13:09:19 -0700
!Lines: 49
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: mx1.captaris.com 12.129.11.151
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:168051
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!Folks,
!
!I've been running into problems with a multipage Tif viewer that I wrote to
!display fax images in an ASP.Net app. I've been basically following the
!standard examples on how to do this:
!
!- Read the image from a file
!- set the current frame
!- write the frame data to an output stream
!
! and ended up with this code:
!
!<snip>
! System.Drawing.Image b;
! System.Drawing.Imaging.FrameDimension frameDim;
!
! //Read Tif from file (todo: change fromFile to stream)
! strFilename = ConfigurationSettings.AppSettings["Images.Dir"] +
!Request["filename"];
! b = System.Drawing.Image.FromFile(strFilename);
!
! //Set current frame
! frameDim = new
!System.Drawing.Imaging.FrameDimension(b.FrameDimensionsList[0]);
! int intFrame = int.Parse(Request["frame"]);
! b.SelectActiveFrame(frameDim,intFrame);
!
! //Save to output stream in jpg format
! Response.ContentType="image/jpeg";
! b.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
! b.Dispose();
!</snip>
!
!Now, this code works fine with Group 4 Tiff files. However, I am dealing
!with Group 3 and here the application throws a "A generic error occurred in
!GDI+."-exception whenever intFrame>0 (basically I can view the first page
!and that's it). I saw other people in newsgroups having the same kind of
!roblem but it never got resolved. Is this a bug in System.Drawing.Image? Is
!there a patch or workaround for this?
!
!Any advice/suggestions/code samples greatly appreciated.
!Thanks
!-Stefan
!
!PS: If needed, I can supply an example Tif for both Group3/Group4 formats.
!
!
!
!
!
 
Back
Top