vcl/source/gdi/dibtools.cxx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
New commits: commit d6eaa8aa5211f1c140d7e9ed27a7fef806b4af3b Author: Caolán McNamara <caol...@redhat.com> Date: Fri Mar 31 11:04:16 2017 +0100 ofz: 0 bitcount bmps are unsupported Change-Id: Ibd7b25546006506350f9fc009596f2989a305a4c diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index 37408f408154..4cd7c5419199 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -772,6 +772,10 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL if (!ImplReadDIBInfoHeader(rIStm, aHeader, bTopDown, bMSOFormat) && aHeader.nWidth && aHeader.nHeight && aHeader.nBitCount) return false; + //BI_BITCOUNT_0 jpeg/png is unsupported + if (aHeader.nBitCount == 0) + return false; + // In case ImplReadDIB() didn't call ImplReadDIBFileHeader() before // this method, nOffset is 0, that's OK. if (nOffset && aHeader.nSize > nOffset) commit 473066c526ac1d970658b39381436b23d78676ac Author: Caolán McNamara <caol...@redhat.com> Date: Fri Mar 31 09:36:05 2017 +0100 expand forcing to mono mask during load to non-indexed sources too Change-Id: I38c1eec5e180d689de72413b1438c88a1085bbb5 diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index 576c38871918..37408f408154 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -337,6 +337,14 @@ namespace return nIndex; } + + BitmapColor SanitizeColor(const BitmapColor &rColor, bool bForceToMonoWhileReading) + { + if (!bForceToMonoWhileReading) + return rColor; + return BitmapColor(static_cast<sal_uInt8>(rColor.GetLuminance() >= 255)); + } + } bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header& rHeader, BitmapWriteAccess& rAcc, BitmapPalette& rPalette, bool bForceToMonoWhileReading, bool bRLE4) @@ -661,7 +669,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r for( long nX = 0; nX < nWidth; nX++ ) { aMask.GetColorFor16BitLSB( aColor, reinterpret_cast<sal_uInt8*>(pTmp16++) ); - rAcc.SetPixel( nY, nX, aColor ); + rAcc.SetPixel(nY, nX, SanitizeColor(aColor, bForceToMonoWhileReading)); } } } @@ -685,7 +693,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r aPixelColor.SetBlue( *pTmp++ ); aPixelColor.SetGreen( *pTmp++ ); aPixelColor.SetRed( *pTmp++ ); - rAcc.SetPixel( nY, nX, aPixelColor ); + rAcc.SetPixel(nY, nX, SanitizeColor(aPixelColor, bForceToMonoWhileReading)); } } } @@ -723,7 +731,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r for( long nX = 0; nX < nWidth; nX++ ) { aMask.GetColorAndAlphaFor32Bit( aColor, aAlpha, reinterpret_cast<sal_uInt8*>(pTmp32++) ); - rAcc.SetPixel( nY, nX, aColor ); + rAcc.SetPixel(nY, nX, SanitizeColor(aColor, bForceToMonoWhileReading)); pAccAlpha->SetPixelIndex(nY, nX, sal_uInt8(0xff) - aAlpha); rAlphaUsed |= bool(0xff != aAlpha); } @@ -743,7 +751,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r for( long nX = 0; nX < nWidth; nX++ ) { aMask.GetColorFor32Bit( aColor, reinterpret_cast<sal_uInt8*>(pTmp32++) ); - rAcc.SetPixel( nY, nX, aColor ); + rAcc.SetPixel(nY, nX, SanitizeColor(aColor, bForceToMonoWhileReading)); } } }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits