diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-12-05 11:35:57 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-12-05 18:35:47 +0100 |
commit | 1ceb4f36a7cabe7a0fb2b0c2e36079389d6a69b2 (patch) | |
tree | 862b67549d4804f79c346b0f9f2011340ca9d22a /sfx2 | |
parent | 19c8404ff66e259787ec28e067c2a5828b7df3be (diff) |
generate a thumbnail to save without a metafile
This is similar to 59cca1a28df4cdc94450d68cc1e247a8fb5ff6f3,
if the wanted result is a bitmap, there's not much point first
converting to metafile and then to a bitmap.
Change-Id: I594e1e47bc499acf42f6a551f4114091dcf75b15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126375
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/graphhelp.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/doc/graphhelp.hxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 6 |
3 files changed, 10 insertions, 16 deletions
diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index b309625206a5..04b55df9c18c 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -170,11 +170,9 @@ void* GraphicHelper::getWinMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta, co // static -bool GraphicHelper::getThumbnailFormatFromGDI_Impl(GDIMetaFile const * pMetaFile, const uno::Reference<io::XStream>& xStream) +bool GraphicHelper::getThumbnailFormatFromBitmap_Impl(const BitmapEx& rBitmap, const uno::Reference<io::XStream>& xStream) { - bool bResult = false; - - if (!pMetaFile || !xStream.is()) + if (rBitmap.IsEmpty() || !xStream.is()) return false; std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xStream)); @@ -182,16 +180,12 @@ bool GraphicHelper::getThumbnailFormatFromGDI_Impl(GDIMetaFile const * pMetaFile if (pStream->GetError()) return false; - BitmapEx aResultBitmap; - - bResult = pMetaFile->CreateThumbnail(aResultBitmap, BmpConversion::N8BitColors, BmpScaleFlag::Default); - - if (!bResult || aResultBitmap.IsEmpty()) - return false; + BitmapEx bitmap(rBitmap); + bitmap.Convert(BmpConversion::N8BitColors); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - if (rFilter.compressAsPNG(aResultBitmap, *pStream) != ERRCODE_NONE) + if (rFilter.compressAsPNG(bitmap, *pStream) != ERRCODE_NONE) return false; pStream->Flush(); diff --git a/sfx2/source/doc/graphhelp.hxx b/sfx2/source/doc/graphhelp.hxx index e0129c917b1e..1945661fc12f 100644 --- a/sfx2/source/doc/graphhelp.hxx +++ b/sfx2/source/doc/graphhelp.hxx @@ -53,8 +53,8 @@ public: #endif } - static bool getThumbnailFormatFromGDI_Impl( - GDIMetaFile const * pMetaFile, + static bool getThumbnailFormatFromBitmap_Impl( + const BitmapEx& rBitmap, const css::uno::Reference< css::io::XStream >& xStream ); static OUString getThumbnailReplacementIDByFactoryName_Impl( diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 89e458705efe..8b3c8f6d3e9d 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -3647,10 +3647,10 @@ bool SfxObjectShell::WriteThumbnail(bool bEncrypted, const uno::Reference<io::XS } else { - std::shared_ptr<GDIMetaFile> xMetaFile = GetPreviewMetaFile(); - if (xMetaFile) + BitmapEx bitmap = GetPreviewBitmap(); + if (!bitmap.IsEmpty()) { - bResult = GraphicHelper::getThumbnailFormatFromGDI_Impl(xMetaFile.get(), xStream); + bResult = GraphicHelper::getThumbnailFormatFromBitmap_Impl(bitmap, xStream); } } } |