include/vcl/BitmapTools.hxx | 4 ++++ vcl/source/bitmap/BitmapTools.cxx | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+)
New commits: commit 4a4fd38c876768f28f9c1f0a99faf385515576bc Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> Date: Thu Oct 27 18:18:23 2016 +0200 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 <qui...@gmail.com> Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx index c67bbb8..8be1688 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 fe47363..02de420 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());
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits