[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - filter/source
Caolán McNamara
caolanm at redhat.com
Mon Aug 7 11:07:05 UTC 2017
filter/source/graphicfilter/itiff/itiff.cxx | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
New commits:
commit 133010a0efc8715f95e0ea0f66c22352dd55654a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 28 10:07:50 2017 +0100
ofz#2766 ensure palette is large enough for all colors
Change-Id: I4669b473f5975ac74a37025f7c936f13bcfea420
Reviewed-on: https://gerrit.libreoffice.org/40513
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
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 ] ) );
More information about the Libreoffice-commits
mailing list