diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-10-27 18:18:23 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2016-10-29 18:15:04 +0000 |
commit | 4a4fd38c876768f28f9c1f0a99faf385515576bc (patch) | |
tree | 5279972495777e778c4b64b7001f8440ec010a08 | |
parent | 484390a09624f68a8dec01eb5bf06e84cdcb80f6 (diff) |
vcl: add bitmap::loadFromResource with additional flags
Sometimes we want to surpress automatic scaling and converting
for dark theme. This adds a loadFromResource function with
additional flags which makes this possible.
Change-Id: I893cee82ad6942644755f0c5b772fb5f073bbf00
Reviewed-on: https://gerrit.libreoffice.org/30341
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | include/vcl/BitmapTools.hxx | 4 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapTools.cxx | 22 |
2 files changed, 26 insertions, 0 deletions
diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx index c67bbb81f4f3..8be16886fd96 100644 --- a/include/vcl/BitmapTools.hxx +++ b/include/vcl/BitmapTools.hxx @@ -13,12 +13,16 @@ #include <vcl/bitmapex.hxx> #include <tools/stream.hxx> +#include <vcl/implimagetree.hxx> + namespace vcl { namespace bitmap { +BitmapEx VCL_DLLPUBLIC loadFromResource(const ResId& rResId, const ImageLoadFlags eFlags = ImageLoadFlags::NONE); + void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx, double fScaleFactor = 1.0); } diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index fe4736326036..02de4209adc1 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -21,6 +21,10 @@ #include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp> +#include <tools/resmgr.hxx> +#include <tools/rc.h> +#include <vcl/svapp.hxx> + using namespace css; using drawinglayer::primitive2d::Primitive2DSequence; @@ -32,6 +36,24 @@ namespace vcl namespace bitmap { +BitmapEx loadFromResource(const ResId& rResId, const ImageLoadFlags eFlags) +{ + BitmapEx aBitmapEx; + + ResMgr* pResMgr = nullptr; + + ResMgr::GetResourceSkipHeader(rResId.SetRT( RSC_BITMAP ), &pResMgr); + pResMgr->ReadLong(); + pResMgr->ReadLong(); + + const OUString aFileName(pResMgr->ReadString()); + OUString aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme(); + + ImplImageTree::get().loadImage(aFileName, aIconTheme, aBitmapEx, true, eFlags); + + return aBitmapEx; +} + void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx, double fScalingFactor) { uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext()); |