summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2022-04-21 11:54:49 +0200
committerJulien Nabet <serval2412@yahoo.fr>2022-04-28 12:40:21 +0200
commitbd1d0967920655ef85a2352259332f99fef6876e (patch)
treef861c6e102276311687f0b4e70619aa170e757b5
parent12dcfc191bc258b51f5d00f46ea44a6a1c6fda91 (diff)
tdf#74331: 16bit "min-is-black" tiff not loaded correctly
Since 16 bits part is well taken into account for photometric interpretation "RGB", just consider greyscale as subcase of rgb since greys are just "RGB" colors with same value for red, green and blue Finally, in ConvertScanline, nPhotometricInterpretation <= 1 (so "min is white" and "min is black") with nSamplesPerPixel = 1 corresponds to nDstBitsPerPixel = 8 here, so consider this specific case in the same block. The last piece to adjust is when calling SetPixel: nPhotometricInterpretation = 1 corresponds to the same case as nPhotometricInterpretation = 2 since RGB black is 0, nPhotometricInterpretation = 1 is minisblack so here too black is 0 Change-Id: I5c8e420f851ed6e31998c0698d86300aaa7c4b19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133251 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--vcl/source/filter/itiff/itiff.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/vcl/source/filter/itiff/itiff.cxx b/vcl/source/filter/itiff/itiff.cxx
index 7fa66b746c5d..c9f73a742875 100644
--- a/vcl/source/filter/itiff/itiff.cxx
+++ b/vcl/source/filter/itiff/itiff.cxx
@@ -859,7 +859,7 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
sal_uInt32 nRed, nGreen, nBlue, ns, nVal;
sal_uInt8 nByteVal;
- if ( nDstBitsPerPixel == 24 )
+ if ( nDstBitsPerPixel == 24 || (nDstBitsPerPixel == 8 && nPhotometricInterpretation <= 1 && nSamplesPerPixel == 1) )
{
if ( nBitsPerSample == 8 && nSamplesPerPixel >= 3 &&
nPlanes == 1 && nPhotometricInterpretation == 2 )
@@ -904,7 +904,8 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
}
else if (
( nPhotometricInterpretation == 2 && nSamplesPerPixel >= 3 ) ||
- ( nPhotometricInterpretation == 5 && nSamplesPerPixel == 3 )
+ ( nPhotometricInterpretation == 5 && nSamplesPerPixel == 3 ) ||
+ ( nPhotometricInterpretation <= 1 && nSamplesPerPixel == 1 )
)
{
if ( nMaxSampleValue > nMinSampleValue )
@@ -924,7 +925,7 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
nGreen = GetBits( getMapData(1), nx * nBitsPerSample, nBitsPerSample );
nBlue = GetBits( getMapData(2), nx * nBitsPerSample, nBitsPerSample );
}
- if (nPhotometricInterpretation == 2)
+ if (nPhotometricInterpretation == 1 || nPhotometricInterpretation == 2)
SetPixel(nY, nx, Color(static_cast<sal_uInt8>(nRed - nMinMax), static_cast<sal_uInt8>(nGreen - nMinMax), static_cast<sal_uInt8>(nBlue - nMinMax)));
else
SetPixel(nY, nx, Color(255 - static_cast<sal_uInt8>(nRed - nMinMax), 255 - static_cast<sal_uInt8>(nGreen - nMinMax), 255 - static_cast<sal_uInt8>(nBlue - nMinMax)));