diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-13 15:40:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-14 14:55:57 +0100 |
commit | cb0ace39523acb14ced26ff6f349d228884f02b6 (patch) | |
tree | 5fd92b030af0aa36c372b28cc37146ab59971e29 /svx | |
parent | b90e098a354323b635bab3ee8f9c79deb1e734fe (diff) |
move Bitmap creation in createDefaultCross_3x3 to vcl
part of making Bitmap an internal detail of vcl/
Change-Id: Id6ac7a2b099dca41cf41bb9f65c7cc22dce1eb8e
Reviewed-on: https://gerrit.libreoffice.org/49654
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sdr/primitive2d/sdrprimitivetools.cxx | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx index 31758b6d8a7a..6b8a61ea4b01 100644 --- a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx +++ b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx @@ -18,9 +18,9 @@ */ #include <sdr/primitive2d/sdrprimitivetools.hxx> -#include <vcl/bitmapaccess.hxx> #include <osl/mutex.hxx> #include <vcl/lazydelete.hxx> +#include <vcl/BitmapTools.hxx> // helper methods @@ -32,43 +32,31 @@ namespace drawinglayer BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor) { static vcl::DeleteOnDeinit< BitmapEx > aRetVal(nullptr); - static basegfx::BColor aColor; + static basegfx::BColor aBColor; static ::osl::Mutex aMutex; ::osl::MutexGuard aGuard(aMutex); - if(!aRetVal.get() || rBColor != aColor) + if(!aRetVal.get() || rBColor != aBColor) { // copy values - aColor = rBColor; + aBColor = rBColor; // create bitmap - Bitmap aContent(Size(3, 3), 24); - Bitmap aMask(Size(3, 3), 1); - BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess(); - BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess(); - OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)"); - const Color aVCLColor(aColor); - const BitmapColor aPixColor(aVCLColor); - const BitmapColor aMaskColor(0x01); - - // Y,X unusual order (!) - pWContent->SetPixel(0, 1, aPixColor); - pWContent->SetPixel(1, 0, aPixColor); - pWContent->SetPixel(1, 1, aPixColor); - pWContent->SetPixel(1, 2, aPixColor); - pWContent->SetPixel(2, 1, aPixColor); - - pWMask->SetPixel(0, 0, aMaskColor); - pWMask->SetPixel(0, 2, aMaskColor); - pWMask->SetPixel(2, 0, aMaskColor); - pWMask->SetPixel(2, 2, aMaskColor); - - Bitmap::ReleaseAccess(pWContent); - Bitmap::ReleaseAccess(pWMask); + Color c(aBColor); + sal_uInt8 r = c.GetRed(); + sal_uInt8 g = c.GetGreen(); + sal_uInt8 b = c.GetBlue(); + sal_uInt8 a = 255; + const sal_uInt8 cross[] = { + 0, 0, 0, a, r, g, b, 0, 0, 0, 0, a, + r, g, b, 0, r, g, b, 0, r, g, b, 0, + 0, 0, 0, a, r, g, b, 0, 0, 0, 0, a + }; + BitmapEx aBitmap = vcl::bitmap::CreateFromData(cross, 3, 3, 3, 32); // create and exchange at aRetVal - delete aRetVal.set(new BitmapEx(aContent, aMask)); + delete aRetVal.set(new BitmapEx(aBitmap)); } return aRetVal.get() ? *aRetVal.get() : BitmapEx(); |