summaryrefslogtreecommitdiff
path: root/sfx2/source/doc/graphhelp.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-09-21 21:34:01 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-09-22 00:31:49 +0200
commit2113c50b455ae67874eb61ff0dcd75c766b17002 (patch)
tree74d304ba65cc346422d182c5ebce66b2dec9b7c7 /sfx2/source/doc/graphhelp.cxx
parent3a7e54f5d2020ea1f6f2b27a51f5ca065844837f (diff)
fdo#62104 Optimize thumbnail size by using PNG8 and other tricks
Change-Id: I54ece4a1977fe93c0e7bbb11774bd8657912c6bb
Diffstat (limited to 'sfx2/source/doc/graphhelp.cxx')
-rw-r--r--sfx2/source/doc/graphhelp.cxx38
1 files changed, 21 insertions, 17 deletions
diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx
index f1d0bc5047c7..27411314f978 100644
--- a/sfx2/source/doc/graphhelp.cxx
+++ b/sfx2/source/doc/graphhelp.cxx
@@ -39,6 +39,7 @@
#include <vcl/outdev.hxx>
#include <vcl/virdev.hxx>
#include <vcl/bitmapex.hxx>
+#include <vcl/graphicfilter.hxx>
#include <tools/stream.hxx>
#include <tools/helpers.hxx>
@@ -52,7 +53,7 @@
#include "graphhelp.hxx"
#include "doc.hrc"
-using namespace ::com::sun::star;
+using namespace css;
SvMemoryStream* GraphicHelper::getFormatStrFromGDI_Impl( const GDIMetaFile* pGDIMeta, sal_uInt32 nFormat )
{
@@ -192,30 +193,33 @@ bool GraphicHelper::supportsMetaFileHandle_Impl()
// static
-bool GraphicHelper::getThumbnailFormatFromGDI_Impl( GDIMetaFile* pMetaFile,
- const uno::Reference< io::XStream >& xStream )
+bool GraphicHelper::getThumbnailFormatFromGDI_Impl(GDIMetaFile* pMetaFile, const uno::Reference<io::XStream>& xStream)
{
bool bResult = false;
- SvStream* pStream = NULL;
- if ( xStream.is() )
- pStream = ::utl::UcbStreamHelper::CreateStream( xStream );
+ if (!pMetaFile || !xStream.is())
+ return false;
- if ( pMetaFile && pStream && !pStream->GetError() )
- {
- BitmapEx aResultBitmap;
+ boost::scoped_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xStream));
- bResult = pMetaFile->CreateThumbnail(aResultBitmap);
+ if (pStream->GetError())
+ return false;
- if ( bResult )
- bResult = ( !aResultBitmap.IsEmpty()
- && GraphicConverter::Export( *pStream, aResultBitmap, CVT_PNG ) == 0
- && ( pStream->Flush(), !pStream->GetError() ) );
+ BitmapEx aResultBitmap;
- delete pStream;
- }
+ bResult = pMetaFile->CreateThumbnail(aResultBitmap, 256, BMP_CONVERSION_8BIT_COLORS, BMP_SCALE_DEFAULT);
- return bResult;
+ if (!bResult || aResultBitmap.IsEmpty())
+ return false;
+
+ GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+
+ if (rFilter.compressAsPNG(aResultBitmap, *pStream.get(), 9) != GRFILTER_OK)
+ return false;
+
+ pStream->Flush();
+
+ return !pStream->GetError();
}
// static