简体   繁体   中英

BitMiracle.LibTiff.Net Converting oJPEG tiff to Bitmap results in a negative color image

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.

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM