summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2022-04-18 12:26:39 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-04-28 21:20:40 +0200
commitab3bfc464f681c715f04b6c3135b850bab8576d3 (patch)
treebb8afe627a33562b3e3254a3725b591a62d6eae2 /vcl/source
parent5277b953b29845555cba8f867c9c750e8bc510a5 (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 (cherry picked from commit dc97aac5cdfa3789d4e71e9d92df6e7e68802825) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133485 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl/source')
-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 25c8af8b6582..cad78f1b7d1f 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)));
}
}
}