[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - vcl/headless vcl/source
Vasily Melenchuk
Vasily.Melenchuk at cib.de
Wed Feb 28 22:24:54 UTC 2018
vcl/headless/svpgdi.cxx | 31 +++++++++++++++++++++++++++++++
vcl/source/gdi/pngread.cxx | 10 +---------
2 files changed, 32 insertions(+), 9 deletions(-)
New commits:
commit 355a6ecfe000677e09ec959b52a7b29d1e8fc8e2
Author: Vasily Melenchuk <Vasily.Melenchuk at cib.de>
Date: Tue Feb 27 19:08:35 2018 +0300
tdf#115297: alternative fix for displaying 1bit images
Previous fixes for 1bit monochrome / paletted images produced some
regressions, so here is attempt to fix problem at the root.
Partially reverted 66dbd4da3afcadb1393daf9be9cecff71b86509a and
fixed in a different way without tdf#115297, tdf#114726 and related.
Reviewed-on: https://gerrit.libreoffice.org/50454
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
(cherry picked from commit 25cd843664919974f0d21ca7a0b02cc43e9eeabb)
Conflicts:
vcl/headless/svpgdi.cxx
vcl/source/gdi/pngread.cxx
Change-Id: I6849ed5ac41770ba905c930065c80e58509dba2e
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 11f408aaf773..4a3874f4586b 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1014,8 +1014,39 @@ 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 && isBlackWhite(rSourceBitmap))
+ {
+ // This way we draw only monochrome b/w bitmaps
+ MaskHelper aMask(rSourceBitmap);
+ cairo_surface_t* source = aMask.getMask();
+ copySource(rTR, source);
+ return;
+ }
+
SourceHelper aSurface(rSourceBitmap);
cairo_surface_t* source = aSurface.getSurface();
if (!source)
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 6850e13bc802..85de3b6cff8a 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -548,19 +548,11 @@ bool PNGReaderImpl::ImplReadHeader( const Size& rPreviewSizeHint )
{
switch ( mnPngDepth )
{
- case 1 :
-#if defined(UNX) && !defined(MAXOSX)
- // 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;
More information about the Libreoffice-commits
mailing list