Corne
Corne

Reputation: 646

Windows 7: Saving as TIFF CCITT Group4 changed?

My program, that converts a multi page TIFF to PDF is not longer working under Windows 7. The program contains code that walks through the pages of the TIFF, converts each page as TIFF with CCITT Group4 compression and inserts the bitmap data in the resulting PDF file.

Converting is done in the following way (c#):

 ImageCodecInfo tiffCodecInfo = GetEncoderInfo("image/tiff");
 EncoderParameters myEncoderParameters = new EncoderParameters(2);

 // Save the bitmap as a TIFF file with CCITT group4 compression.       
 myEncoderParameters.Param[0] = new EncoderParameter System.Drawing.Imaging.Encoder.Compression, (long)EncoderValue..CompressionCCITT4);
 myEncoderParameters.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 1L);
 image.Save(source, tiffCodecInfo, myEncoderParameters);

It seems that the behaviour of GDI+ is changed in Windows 7: The resulting CCITT bitmap data is no longer encoded in a single strip. Because of this I cannot use this bitmap data in my PDF file.

Question: does anybody know how I can tell GDI+ to encode the bitmap data in a single strip?

Upvotes: 1

Views: 4493

Answers (2)

rwong
rwong

Reputation: 6162

The short answer is that: If you want to stay with GDI+ (or its .NET counterpart System.Drawing.Imaging), you'll be subjected to its limitations. This is because Microsoft controls its implementation, and it is their decision not to implement certain features or customization points or to do certain tasks in a particular way.

Therefore my answer to that is to use an alternative, such as Windows Imaging Component (WIC, or its .NET counterpart System.Windows.Media.Imaging, found in PresentationCore).

Note that the .NET implementation (wrapper) of WIC has some crippling issues, such as not being fully thread-safe. (It may be sufficient for hobby and consumer applications, not for production-grade server-side applications.)

This is one reason I suggest using a .NET library for TIFF that isn't dependent on PresentationCore.

http://bitmiracle.com/libtiff/

See also: Using LibTiff from C# (to access tiled TIFF images)

Upvotes: 1

Corne
Corne

Reputation: 646

I received an answer from Microsoft:

Yes, in Windows 7 we did extensive work to the TIFF CODEC. One of the pieces of work was to support decoding and encoding in multiple strips. Unfortunately there is no way to control the number of strips outputted by the encoder.

Upvotes: 1

Related Questions