summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2022-04-18 12:26:39 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2022-04-19 10:23:39 +0200
commitdc97aac5cdfa3789d4e71e9d92df6e7e68802825 (patch)
tree8073fd415afc750c723e15ca6766c251457178c9
parent41560f52a93602b61253e942d8a88046745c16aa (diff)
Following tdf#142151: Red cast rendered in 16 bit TIFF image
Just simplify by merging both almost identical parts. Change-Id: I1658621609e10312feed530090adfa873602d2f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133115 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--vcl/source/filter/itiff/itiff.cxx34
1 files changed, 7 insertions, 27 deletions
diff --git a/vcl/source/filter/itiff/itiff.cxx b/vcl/source/filter/itiff/itiff.cxx
index 5e54eeaa155a..7fa66b746c5d 100644
--- a/vcl/source/filter/itiff/itiff.cxx
+++ b/vcl/source/filter/itiff/itiff.cxx
@@ -902,7 +902,10 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
}
}
}
- else if ( nPhotometricInterpretation == 2 && nSamplesPerPixel >= 3 )
+ else if (
+ ( nPhotometricInterpretation == 2 && nSamplesPerPixel >= 3 ) ||
+ ( nPhotometricInterpretation == 5 && nSamplesPerPixel == 3 )
+ )
{
if ( nMaxSampleValue > nMinSampleValue )
{
@@ -921,33 +924,10 @@ bool TIFFReader::ConvertScanline(sal_Int32 nY)
nGreen = GetBits( getMapData(1), nx * nBitsPerSample, nBitsPerSample );
nBlue = GetBits( getMapData(2), nx * nBitsPerSample, nBitsPerSample );
}
- SetPixel(nY, nx, Color(static_cast<sal_uInt8>(nRed - nMinMax), static_cast<sal_uInt8>(nGreen - nMinMax), static_cast<sal_uInt8>(nBlue - nMinMax)));
- }
- }
- }
- else if ( nPhotometricInterpretation == 5 && nSamplesPerPixel == 3 )
- {
- if ( nMaxSampleValue > nMinSampleValue )
- {
- sal_uInt32 nMinMax = nMinSampleValue * 255 / ( nMaxSampleValue - nMinSampleValue );
- for (sal_Int32 nx = 0; nx < nImageWidth; ++nx)
- {
- if ( nPlanes < 3 )
- {
- nRed = GetBits( getMapData(0), ( nx * nSamplesPerPixel + 0 ) * nBitsPerSample, nBitsPerSample );
- nGreen = GetBits( getMapData(0), ( nx * nSamplesPerPixel + 1 ) * nBitsPerSample, nBitsPerSample );
- nBlue = GetBits( getMapData(0), ( nx * nSamplesPerPixel + 2 ) * nBitsPerSample, nBitsPerSample );
- }
+ if (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
- {
- nRed = GetBits( getMapData(0), nx * nBitsPerSample, nBitsPerSample );
- nGreen = GetBits( getMapData(1), nx * nBitsPerSample, nBitsPerSample );
- nBlue = GetBits( getMapData(2), nx * nBitsPerSample, nBitsPerSample );
- }
- nRed = 255 - static_cast<sal_uInt8>( nRed - nMinMax );
- nGreen = 255 - static_cast<sal_uInt8>( nGreen - nMinMax );
- nBlue = 255 - static_cast<sal_uInt8>( nBlue - nMinMax );
- SetPixel(nY, nx, Color(static_cast<sal_uInt8>(nRed), static_cast<sal_uInt8>(nGreen), static_cast<sal_uInt8>(nBlue)));
+ 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)));
}
}
}