diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-07-28 10:07:50 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-08-11 10:48:38 +0200 |
commit | 2cae2622fcf21d3c453dabacf78d3c36c1b038ac (patch) | |
tree | 35ee9c4ff721b882b56515a9304e36a986877547 /filter | |
parent | 084a1fc85f2e9099b89b7a0bc519a8d482645155 (diff) |
ofz#2766 ensure palette is large enough for all colors
Change-Id: I4669b473f5975ac74a37025f7c936f13bcfea420
Reviewed-on: https://gerrit.libreoffice.org/40513
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
(cherry picked from commit 133010a0efc8715f95e0ea0f66c22352dd55654a)
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/graphicfilter/itiff/itiff.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx index db1ddccd1e64..7031d7daee30 100644 --- a/filter/source/graphicfilter/itiff/itiff.cxx +++ b/filter/source/graphicfilter/itiff/itiff.cxx @@ -1111,7 +1111,7 @@ void TIFFReader::MakePalCol() { if ( nDstBitsPerPixel <= 8 ) { - sal_uLong i, nVal, n0RGB; + sal_uLong nVal, n0RGB; if ( pColorMap == nullptr ) pColorMap = new sal_uLong[ 256 ]; if ( nPhotometricInterpretation <= 1 ) @@ -1124,8 +1124,8 @@ void TIFFReader::MakePalCol() SAL_WARN("filter.tiff", "palette has less entries that largest index used. Expanding palette to match"); nNumColors = nLargestPixelIndex + 1; } - pAcc->SetPaletteEntryCount( (sal_uInt16)nNumColors ); - for ( i = 0; i < nNumColors; i++ ) + + for (sal_uLong i = 0; i < nNumColors; ++i) { nVal = ( i * 255 / ( nNumColors - 1 ) ) & 0xff; n0RGB = nVal | ( nVal << 8 ) | ( nVal << 16 ); @@ -1135,7 +1135,8 @@ void TIFFReader::MakePalCol() pColorMap[ nNumColors - i - 1 ] = n0RGB; } } - for ( i = 0; i < nNumColors; i++ ) + pAcc->SetPaletteEntryCount(std::max<sal_uInt16>(nNumColors, pAcc->GetPaletteEntryCount())); + for (sal_uLong i = 0; i < nNumColors; ++i) { pAcc->SetPaletteColor( (sal_uInt16)i, BitmapColor( (sal_uInt8)( pColorMap[ i ] >> 16 ), (sal_uInt8)( pColorMap[ i ] >> 8 ), (sal_uInt8)pColorMap[ i ] ) ); |