[Libreoffice-commits] core.git: svx/source

Noel Grandin noel.grandin at collabora.co.uk
Wed Feb 14 13:56:20 UTC 2018


 svx/source/sdr/primitive2d/sdrprimitivetools.cxx |   44 ++++++++---------------
 1 file changed, 16 insertions(+), 28 deletions(-)

New commits:
commit cb0ace39523acb14ced26ff6f349d228884f02b6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Feb 13 15:40:47 2018 +0200

    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 at collabora.com>
    Tested-by: Jenkins <ci at libreoffice.org>

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();


More information about the Libreoffice-commits mailing list