diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-03-31 09:36:05 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-03-31 11:05:04 +0100 |
commit | 473066c526ac1d970658b39381436b23d78676ac (patch) | |
tree | 19fc235f9988587d79e38b08f31158bcb64f43fa /vcl | |
parent | cb5b83e322ec3991fbc8e9edbb6389bda1749cac (diff) |
expand forcing to mono mask during load to non-indexed sources too
Change-Id: I38c1eec5e180d689de72413b1438c88a1085bbb5
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/dibtools.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
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)); } } } |