[Libreoffice-commits] .: vcl/unx vcl/win

Caolán McNamara caolan at kemper.freedesktop.org
Mon Mar 28 09:04:37 PDT 2011


 vcl/unx/source/gdi/salgdi2.cxx |   18 +++++++++++++++++-
 vcl/win/source/gdi/makefile.mk |    3 ++-
 vcl/win/source/gdi/salgdi2.cxx |   24 ++++++++++++++++++++++--
 3 files changed, 41 insertions(+), 4 deletions(-)

New commits:
commit 23f0b0c5552323d1556f4b69ad7478cd1e49b449
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 28 17:04:28 2011 +0100

    Resolves: fdo#33455 implement rendering of 1bit pngs palette colors

diff --git a/vcl/unx/source/gdi/salgdi2.cxx b/vcl/unx/source/gdi/salgdi2.cxx
index 8e444ad..3cf4ba1 100644
--- a/vcl/unx/source/gdi/salgdi2.cxx
+++ b/vcl/unx/source/gdi/salgdi2.cxx
@@ -44,6 +44,7 @@
 #include "vcl/salbtype.hxx"
 #include "vcl/printergfx.hxx"
 #include "vcl/bmpacc.hxx"
+#include "vcl/outdata.hxx"
 
 #undef SALGDI2_TESTTRANS
 
@@ -627,7 +628,22 @@ void X11SalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSa
     {
         // set foreground/background values for 1Bit bitmaps
         XGetGCValues( pXDisp, aGC, nValues, &aOldVal );
-        aNewVal.foreground = rColMap.GetWhitePixel(), aNewVal.background = rColMap.GetBlackPixel();
+
+        aNewVal.foreground = rColMap.GetWhitePixel();
+        aNewVal.background = rColMap.GetBlackPixel();
+
+        //fdo#33455 handle 1 bit depth pngs with palette entries
+        //to set fore/back colors
+        if (const BitmapBuffer* pBitmapBuffer = const_cast<SalBitmap&>(rSalBitmap).AcquireBuffer(true))
+        {
+            const BitmapPalette& rPalette = pBitmapBuffer->maPalette;
+            if (rPalette.GetEntryCount() == 2)
+            {
+                aNewVal.foreground = rColMap.GetPixel(ImplColorToSal(rPalette[0]));
+                aNewVal.background = rColMap.GetPixel(ImplColorToSal(rPalette[1]));
+            }
+        }
+
         XChangeGC( pXDisp, aGC, nValues, &aNewVal );
     }
     
diff --git a/vcl/win/source/gdi/makefile.mk b/vcl/win/source/gdi/makefile.mk
index 1863364..07a8bf5 100644
--- a/vcl/win/source/gdi/makefile.mk
+++ b/vcl/win/source/gdi/makefile.mk
@@ -58,7 +58,8 @@ SLOFILES=   $(SLO)$/salgdi.obj   \
             $(SLO)$/salnativewidgets-luna.obj
 
 
-EXCEPTIONSFILES=	$(SLO)$/salprn.obj
+EXCEPTIONSFILES=	$(SLO)$/salprn.obj \
+					$(SLO)$/salgdi2.obj
 
 .IF "$(ENABLE_GRAPHITE)" == "TRUE"
 CFLAGS+=-DENABLE_GRAPHITE
diff --git a/vcl/win/source/gdi/salgdi2.cxx b/vcl/win/source/gdi/salgdi2.cxx
index 2cab0c8..63573f4 100644
--- a/vcl/win/source/gdi/salgdi2.cxx
+++ b/vcl/win/source/gdi/salgdi2.cxx
@@ -40,6 +40,10 @@
 #include <salgdi.h>
 #include <salframe.h>
 
+#include "vcl/salbtype.hxx"
+#include "vcl/bmpacc.hxx"
+#include "vcl/outdata.hxx"
+
 bool WinSalGraphics::supportsOperation( OutDevSupportType eType ) const
 {
     static bool bAllowForTest(true);
@@ -391,8 +395,24 @@ void ImplDrawBitmap( HDC hDC,
 
             if( bMono )
             {
-                nOldBkColor = SetBkColor( hDC, RGB( 0xFF, 0xFF, 0xFF ) );
-                nOldTextColor = ::SetTextColor( hDC, RGB( 0x00, 0x00, 0x00 ) );
+                COLORREF nBkColor = RGB( 0xFF, 0xFF, 0xFF );
+                COLORREF nTextColor = RGB( 0x00, 0x00, 0x00 );
+                //fdo#33455 handle 1 bit depth pngs with palette entries
+                //to set fore/back colors
+                if (const BitmapBuffer* pBitmapBuffer = const_cast<WinSalBitmap&>(rSalBitmap).AcquireBuffer(true))
+                {
+                    const BitmapPalette& rPalette = pBitmapBuffer->maPalette;
+                    if (rPalette.GetEntryCount() == 2)
+                    {
+                        SalColor nCol;
+                        nCol = ImplColorToSal(rPalette[0]);
+                        nTextColor = RGB( SALCOLOR_RED(nCol), SALCOLOR_GREEN(nCol), SALCOLOR_BLUE(nCol) );
+                        nCol = ImplColorToSal(rPalette[1]);
+                        nBkColor = RGB( SALCOLOR_RED(nCol), SALCOLOR_GREEN(nCol), SALCOLOR_BLUE(nCol) );
+                    }
+                }
+                nOldBkColor = SetBkColor( hDC, nBkColor );
+                nOldTextColor = ::SetTextColor( hDC, nTextColor );
             }
 
             if ( (pPosAry->mnSrcWidth  == pPosAry->mnDestWidth) &&


More information about the Libreoffice-commits mailing list