Kaydet (Commit) 3a7e54f5 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Convenient function to compress a Graphic to PNG image

Change-Id: I3d30dd4337b6bd3b5b0c7cdf97a8787c4bc37fa3
üst 6b894d17
...@@ -320,6 +320,8 @@ public: ...@@ -320,6 +320,8 @@ public:
Graphic& rGraphic, Graphic& rGraphic,
GraphicFilter* pFilter = NULL, GraphicFilter* pFilter = NULL,
sal_uInt16* pDeterminedFormat = NULL ); sal_uInt16* pDeterminedFormat = NULL );
sal_uInt16 compressAsPNG(const Graphic& rGraphic, SvStream& rOutputStream, sal_uInt32 nCompression = 5);
}; };
#endif // INCLUDED_VCL_GRAPHICFILTER_HXX #endif // INCLUDED_VCL_GRAPHICFILTER_HXX
......
...@@ -2302,4 +2302,16 @@ int GraphicFilter::LoadGraphic( const OUString &rPath, const OUString &rFilterNa ...@@ -2302,4 +2302,16 @@ int GraphicFilter::LoadGraphic( const OUString &rPath, const OUString &rFilterNa
return nRes; return nRes;
} }
sal_uInt16 GraphicFilter::compressAsPNG(const Graphic& rGraphic, SvStream& rOutputStream, sal_uInt32 nCompression)
{
nCompression = MinMax(nCompression, 0, 100);
uno::Sequence<beans::PropertyValue> aFilterData(1);
aFilterData[0].Name = "Compression";
aFilterData[0].Value <<= nCompression;
sal_uInt16 nFilterFormat = GetExportFormatNumberForShortName("PNG");
return ExportGraphic(rGraphic, OUString(), rOutputStream, nFilterFormat, &aFilterData);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment