[Libreoffice-commits] .: canvas/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Oct 15 06:51:47 PDT 2012
canvas/source/cairo/cairo_canvashelper.cxx | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
New commits:
commit 0c120f9dd429e035c1e4595c702411241c4431ea
Author: Michael Stahl <mstahl at redhat.com>
Date: Mon Oct 15 15:47:09 2012 +0200
cairo canvas: handle 8-bit grey-scale alpha colors:
Apparently BitmapReadAccess::ImplCreate creates non-indexed color
palettes in case of grey-scale, which leads to one assertion from
BitmapColor::GetIndex() per pixel if that is accessed incorrectly;
handle this better in cairo canvas.
Change-Id: Idcdc3fbe182db948d25e744cb484e2db932c7868
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index 0ecddee..8c0f03e 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -339,6 +339,22 @@ namespace cairocanvas
return ::BitmapEx();
}
+ static sal_uInt8 lcl_GetColor(BitmapColor const& rColor)
+ {
+ sal_uInt8 nTemp(0);
+ if (rColor.IsIndex())
+ {
+ nTemp = rColor.GetIndex();
+ }
+ else
+ {
+ nTemp = rColor.GetBlue();
+ // greyscale expected here, or what would non-grey colors mean?
+ assert(rColor.GetRed() == nTemp && rColor.GetGreen() == nTemp);
+ }
+ return nTemp;
+ }
+
static bool readAlpha( BitmapReadAccess* pAlphaReadAcc, long nY, const long nWidth, unsigned char* data, long nOff )
{
bool bIsAlpha = false;
@@ -364,7 +380,10 @@ namespace cairocanvas
pReadScan = pAlphaReadAcc->GetScanline( nY );
for( nX = 0; nX < nWidth; nX++ )
{
- nAlpha = data[ nOff ] = 255 - ( pAlphaReadAcc->GetPaletteColor( *pReadScan++ ).GetIndex() );
+ BitmapColor const& rColor(
+ pAlphaReadAcc->GetPaletteColor(*pReadScan));
+ pReadScan++;
+ nAlpha = data[ nOff ] = 255 - lcl_GetColor(rColor);
if( nAlpha != 255 )
bIsAlpha = true;
nOff += 4;
More information about the Libreoffice-commits
mailing list