[Libreoffice-commits] core.git: vcl/source

Marco Cecchetti marco.cecchetti at collabora.com
Wed Feb 24 15:08:06 UTC 2016


 vcl/source/gdi/pdfextoutdevdata.cxx |   16 +++++++++++-----
 vcl/source/gdi/pdfwriter_impl2.cxx  |   10 ++++++++--
 2 files changed, 19 insertions(+), 7 deletions(-)

New commits:
commit eab3c3ab9da5f0282df43d2f4bfbf17f7a4f8fe3
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Fri Feb 19 18:12:49 2016 +0100

    tdf#97662 - Avoid JPEG compressing de-compressed PNG.
    
    Change-Id: Iafa5d4b347da46dedb9431b6870f34b2b6fcad99

diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx
index c5df5b6..1205787 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -409,15 +409,21 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
                     else if ( aBeg->eAct == PDFExtOutDevDataSync::EndGroupGfxLink )
                     {
                         Graphic& rGraphic = mGraphics.front();
-                        if ( rGraphic.IsLink() &&
-                             rGraphic.GetLink().GetType() == GFX_LINK_TYPE_NATIVE_JPG &&
-                             mParaRects.size() >= 2 )
+                        if ( rGraphic.IsLink() )
                         {
-                            mbGroupIgnoreGDIMtfActions =
+                            GfxLinkType eType = rGraphic.GetLink().GetType();
+                            if ( eType == GFX_LINK_TYPE_NATIVE_JPG && mParaRects.size() >= 2 )
+                            {
+                                mbGroupIgnoreGDIMtfActions =
                                 rOutDevData.HasAdequateCompression(
                                         rGraphic, mParaRects[0], mParaRects[1]);
-                            if ( !mbGroupIgnoreGDIMtfActions )
+                                if ( !mbGroupIgnoreGDIMtfActions )
+                                    mCurrentGraphic = rGraphic;
+                            }
+                            else if ( eType == GFX_LINK_TYPE_NATIVE_PNG )
+                            {
                                 mCurrentGraphic = rGraphic;
+                            }
                         }
                         break;
                     }
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index f78f52e..404d0c8 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -96,7 +96,13 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
             aBitmapEx.Mirror( nMirrorFlags );
         }
 
-        bool bIsJpeg = (i_Graphic.GetType() != GRAPHIC_NONE) && (i_Graphic.GetBitmapEx() == aBitmapEx);
+        bool bIsJpeg = false, bIsPng = false;
+        if( i_Graphic.GetType() != GRAPHIC_NONE && i_Graphic.GetBitmapEx() == aBitmapEx )
+        {
+            GfxLinkType eType = i_Graphic.GetLink().GetType();
+            bIsJpeg = (eType == GFX_LINK_TYPE_NATIVE_JPG);
+            bIsPng = (eType == GFX_LINK_TYPE_NATIVE_PNG);
+        }
 
         if( i_rContext.m_nMaxImageResolution > 50 )
         {
@@ -154,7 +160,7 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
                     aBitmapEx.Convert( eConv );
             }
             bool bUseJPGCompression = !i_rContext.m_bOnlyLosslessCompression;
-            if ( ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) )
+            if ( bIsPng || ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) )
                 bUseJPGCompression = false;
 
             SvMemoryStream  aStrm;


More information about the Libreoffice-commits mailing list