Kaydet (Commit) 4209a612 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

sb140: #i116872# avoid uninitialized RGB values for full-transparency pixels

plus
sb140: #i116872# optimize for nOpacity == 0 (requested by aw)
üst fd652012
...@@ -62,9 +62,8 @@ namespace ...@@ -62,9 +62,8 @@ namespace
if(nWidth && nHeight) if(nWidth && nHeight)
{ {
const Size aDestSize(nWidth, nHeight); const Size aDestSize(nWidth, nHeight);
sal_uInt8 nInitAlpha(255);
Bitmap aContent(aDestSize, 24); Bitmap aContent(aDestSize, 24);
AlphaMask aAlpha(aDestSize, &nInitAlpha); AlphaMask aAlpha(aDestSize);
BitmapWriteAccess* pContent = aContent.AcquireWriteAccess(); BitmapWriteAccess* pContent = aContent.AcquireWriteAccess();
BitmapWriteAccess* pAlpha = aAlpha.AcquireWriteAccess(); BitmapWriteAccess* pAlpha = aAlpha.AcquireWriteAccess();
...@@ -99,14 +98,20 @@ namespace ...@@ -99,14 +98,20 @@ namespace
} }
nOpacity = nOpacity / nDivisor; nOpacity = nOpacity / nDivisor;
if(nOpacity) if(nOpacity)
{ {
pContent->SetPixel(y, x, BitmapColor( pContent->SetPixel(y, x, BitmapColor(
(sal_uInt8)(nRed / nDivisor), (sal_uInt8)(nRed / nDivisor),
(sal_uInt8)(nGreen / nDivisor), (sal_uInt8)(nGreen / nDivisor),
(sal_uInt8)(nBlue / nDivisor))); (sal_uInt8)(nBlue / nDivisor)));
pAlpha->SetPixel(y, x, BitmapColor(255 - (sal_uInt8)nOpacity)); pAlpha->SetPixel(
y, x,
BitmapColor(255 - (sal_uInt8)nOpacity));
}
else
{
pContent->SetPixel(y, x, BitmapColor(0, 0, 0));
pAlpha->SetPixel(y, x, BitmapColor(255));
} }
} }
} }
...@@ -120,12 +125,8 @@ namespace ...@@ -120,12 +125,8 @@ namespace
for(sal_uInt32 x(0L); x < nWidth; x++) for(sal_uInt32 x(0L); x < nWidth; x++)
{ {
const basegfx::BPixel& rPixel(rRaster.getBPixel(nIndex++)); const basegfx::BPixel& rPixel(rRaster.getBPixel(nIndex++));
pContent->SetPixel(y, x, BitmapColor(rPixel.getRed(), rPixel.getGreen(), rPixel.getBlue()));
if(rPixel.getOpacity()) pAlpha->SetPixel(y, x, BitmapColor(255 - rPixel.getOpacity()));
{
pContent->SetPixel(y, x, BitmapColor(rPixel.getRed(), rPixel.getGreen(), rPixel.getBlue()));
pAlpha->SetPixel(y, x, BitmapColor(255 - rPixel.getOpacity()));
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment