0

I'm using the BitMiracle.LibTiff v2.4.560.0 to convert oJPEG tiffs to Bitmap. This has worked out great until just recently. A Tiff, that I tried converting, is a document with a white background and black text. After converting the tiff, the result ends up with a black background and white text.

I'm using this Convert from Tiff to Bitmap sample for my conversion.

Is this a bug with the BitMiracle.LibTiff library or does there need to be modifications to the sample code? I made quite a few attempts of modifying the sample code, but with no success.

Bobrovsky
  • 13,789
  • 19
  • 80
  • 130
Shar1er80
  • 9,001
  • 2
  • 20
  • 29
  • Can you properly decode the image with the original libtiff? If yes, can you provide the image for testing purposes? – Bobrovsky Nov 14 '16 at 19:38
  • @Bobrovsky, I haven't tried using the original libtiff, since I'm coding in C#. As far as providing the image for testing, I cannot do that as the image contains sensitive material. – Shar1er80 Nov 14 '16 at 20:24

1 Answers1

1

It turns out the image that causes the issue has a TiffTag.PHOTOMETRIC of Photometric.MINISWHITE. Changing that property to Photometric.MINISBLACK resolves the issue.

Added this snippet to Convert from Tiff to Bitmap

FieldValue[] value = tif.GetField(TiffTag.PHOTOMETRIC);
if (value[0].ToInt() == (int)Photometric.MINISWHITE)
{
    tif.SetField(TiffTag.PHOTOMETRIC, Photometric.MINISBLACK);
}
Shar1er80
  • 9,001
  • 2
  • 20
  • 29