summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-06-26 21:06:35 +0100
committerAndras Timar <andras.timar@collabora.com>2014-06-29 14:49:27 -0700
commit4db014a70efbf6f25a63348390c79827caf1c12d (patch)
treefc3cbb4aeb0cd7ff470b95877c843d30d8d6191f /vcl
parentc97f745f328dd2cfccfcda5ed6460aae0085251a (diff)
Resolves: fdo#80160 PNG with 1-bit colormap only show black and white
Change-Id: If0c9950c18e6091fafea47954a4654db436a3a44 (cherry picked from commit 986c0451d05e7bb6ff7edd9f27d0e45532bcd22c) (cherry picked from commit c1df0c41b602ac144fdde4efcf546549443afa86) Reviewed-on: https://gerrit.libreoffice.org/9929 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/generic/gdi/salgdi2.cxx50
1 files changed, 29 insertions, 21 deletions
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index 5c53635c6e45..b92657f51c42 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -445,6 +445,32 @@ void X11SalGraphics::copyArea ( long nDestX, long nDestY,
copyBits ( aPosAry, 0 );
}
+namespace
+{
+ void setForeBack(XGCValues& rValues, const SalColormap& rColMap, const SalBitmap& rSalBitmap)
+ {
+ rValues.foreground = rColMap.GetWhitePixel();
+ rValues.background = rColMap.GetBlackPixel();
+
+ //fdo#33455 and fdo#80160 handle 1 bit depth pngs with palette entries
+ //to set fore/back colors
+ SalBitmap& rBitmap = const_cast<SalBitmap&>(rSalBitmap);
+ if (BitmapBuffer* pBitmapBuffer = rBitmap.AcquireBuffer(true))
+ {
+ const BitmapPalette& rPalette = pBitmapBuffer->maPalette;
+ if (rPalette.GetEntryCount() == 2)
+ {
+ const BitmapColor aWhite(rPalette[rPalette.GetBestIndex(Color(COL_WHITE))]);
+ rValues.foreground = rColMap.GetPixel(ImplColorToSal(aWhite));
+
+ const BitmapColor aBlack(rPalette[rPalette.GetBestIndex(Color(COL_BLACK))]);
+ rValues.background = rColMap.GetPixel(ImplColorToSal(aBlack));
+ }
+ rBitmap.ReleaseBuffer(pBitmapBuffer, true);
+ }
+ }
+}
+
void X11SalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
{
const SalDisplay* pSalDisp = GetDisplay();
@@ -460,24 +486,7 @@ void X11SalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSa
{
// set foreground/background values for 1Bit bitmaps
XGetGCValues( pXDisp, aGC, nValues, &aOldVal );
-
- 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)
- {
- const BitmapColor aBlack( rPalette[rPalette.GetBestIndex( Color( COL_BLACK ) )] );
- const BitmapColor aWhite( rPalette[rPalette.GetBestIndex( Color( COL_WHITE ) )] );
- aNewVal.foreground = rColMap.GetPixel(ImplColorToSal(aWhite));
- aNewVal.background = rColMap.GetPixel(ImplColorToSal(aBlack));
- }
- }
-
+ setForeBack(aNewVal, rColMap, rSalBitmap);
XChangeGC( pXDisp, aGC, nValues, &aNewVal );
}
@@ -530,13 +539,12 @@ void X11SalGraphics::drawMaskedBitmap( const SalTwoRect& rPosAry,
{
GC aTmpGC;
XGCValues aValues;
- const SalColormap& rColMap = pSalDisp->GetColormap( m_nXScreen );
- const int nBlack = rColMap.GetBlackPixel(), nWhite = rColMap.GetWhitePixel();
+ setForeBack(aValues, pSalDisp->GetColormap(m_nXScreen), rSalBitmap);
const int nValues = GCFunction | GCForeground | GCBackground;
SalTwoRect aTmpRect( rPosAry ); aTmpRect.mnDestX = aTmpRect.mnDestY = 0;
// draw paint bitmap in pixmap #1
- aValues.function = GXcopy, aValues.foreground = nWhite, aValues.background = nBlack;
+ aValues.function = GXcopy;
aTmpGC = XCreateGC( pXDisp, aFG, nValues, &aValues );
static_cast<const X11SalBitmap&>(rSalBitmap).ImplDraw( aFG, m_nXScreen, nDepth, aTmpRect, aTmpGC );
DBG_TESTTRANS( aFG );