summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/headless/svpgdi.cxx25
-rw-r--r--vcl/source/gdi/pngread.cxx10
2 files changed, 25 insertions, 10 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index bcb0e46e8bec..67433a2b30e1 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1088,10 +1088,33 @@ void SvpSalGraphics::copyBits( const SalTwoRect& rTR,
cairo_surface_destroy(pCopy);
}
+namespace
+{
+ bool isBlackWhite(const SalBitmap& rBitmap)
+ {
+ const SvpSalBitmap& rSrcBmp = static_cast<const SvpSalBitmap&>(rBitmap);
+ const BitmapBuffer * pSourceBuffer = rSrcBmp.GetBuffer();
+ const BitmapPalette & rPalette = pSourceBuffer->maPalette;
+
+ return (
+ rPalette.GetEntryCount() < 2 ||
+
+ (rPalette.GetEntryCount() == 2 &&
+ rPalette[0] == Color(COL_BLACK) &&
+ rPalette[1] == Color(COL_WHITE) ) ||
+
+ (rPalette.GetEntryCount() == 2 &&
+ rPalette[1] == Color(COL_BLACK) &&
+ rPalette[0] == Color(COL_WHITE) )
+ );
+ }
+}
+
void SvpSalGraphics::drawBitmap(const SalTwoRect& rTR, const SalBitmap& rSourceBitmap)
{
- if (rSourceBitmap.GetBitCount() == 1)
+ if (rSourceBitmap.GetBitCount() == 1 && isBlackWhite(rSourceBitmap))
{
+ // This way we draw only monochrome b/w bitmaps
MaskHelper aMask(rSourceBitmap);
cairo_surface_t* source = aMask.getMask();
copySource(rTR, source);
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 2458d0269e76..0b6946712bc2 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -534,19 +534,11 @@ bool PNGReaderImpl::ImplReadHeader( const Size& rPreviewSizeHint )
{
switch ( mnPngDepth )
{
- case 1 :
-#if defined(UNX) && !defined(MACOSX)
- // 1bpp indexed images are so badly mishandled by rest of LO on X11 that we
- // don't even bother, and turn them into 8bpp indexed ones with just two palette
- // entries instead.
- mnTargetDepth = 8; // we have to expand the bitmap
-#endif
- mbPalette = false;
- break;
case 2 :
mnTargetDepth = 4; // we have to expand the bitmap
mbPalette = false;
break;
+ case 1 :
case 4 :
case 8 :
mbPalette = false;