vcl/source/filter/itiff/itiff.cxx | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-)
New commits: commit ab3bfc464f681c715f04b6c3135b850bab8576d3 Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Mon Apr 18 12:26:39 2022 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Apr 28 21:20:40 2022 +0200 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 <xiscofa...@libreoffice.org> 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))); } } }