diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2016-02-19 18:12:49 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2016-02-24 14:47:56 +0000 |
commit | eab3c3ab9da5f0282df43d2f4bfbf17f7a4f8fe3 (patch) | |
tree | c4773fdf4200df2aa948bf953f0cb46caa689b54 | |
parent | 8a039afb1f3f345c748b2e7cc9b76ca030c23abb (diff) |
tdf#97662 - Avoid JPEG compressing de-compressed PNG.
Change-Id: Iafa5d4b347da46dedb9431b6870f34b2b6fcad99
-rw-r--r-- | vcl/source/gdi/pdfextoutdevdata.cxx | 16 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl2.cxx | 10 |
2 files changed, 19 insertions, 7 deletions
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index c5df5b65c003..120578788dd7 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 f78f52e92ecd..404d0c88c994 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; |