C# Generic GDI+ Error when using Image.Save()

前端 未结 1 1722
你的背包
你的背包 2021-01-23 09:24

I am a relative novice with imaging in C#. This is my first question on this board after a very long time of being a member. I hope it can help me get through this tricky scenar

相关标签:
1条回答
  • 2021-01-23 10:20

    There are 2 useful bits of information in the comment by Hans Passant. First, the TIFF format supports countless sub-types and variations not all of which are supported by GDI+. Second, GDI+ was improved after XP, but not everywhere.

    Your code does work on both Windows XP and Windows 7, but only with the right input TIFF files.

    I tested it using .NET 2.0 and .NET 4.0 programs with 2 input files. The first file had 6 pages, all of which were encoded with LZW compression. This file worked on both Windows 7 and XP.

    The second file had 11 pages with 11 different types of encoding. On Windows XP, only 7 pages out of 11 were loaded correctly. On Windows 7, even fewer pages worked, but the JPEG compression in particular worked correctly although it failed under XP.

    Windows 8.1 fared better than both and managed to load 8 pages correctly.

    You can find the files along with a list of compression types used on this page: http://support.leadtools.com/CS/forums/44475/ShowPost.aspx

    Of course there are other TIFF sub-types, most of which are not supported by GDI+ natively, but these 11 are among the more common formats.

    This leaves us with the problem of getting your files to work on Windows XP. Since they work on Windows 7, there's a strong possibility you have a TIF sub-type that works on Windows 7 but not XP such as JPEG compression. If that's the case, .NET alone will not be enough and you might have to use a dedicated imaging or TIFF library to load such files.

    0 讨论(0)
提交回复
热议问题