diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-16 14:26:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-19 07:12:56 +0100 |
commit | ccd316d1cb310734848bd20244f509024b549b8c (patch) | |
tree | 3f942f2c44c42f4422e8889e94100684e25cf5c4 | |
parent | add367bfec9d12502e64d2994f0f39e2e436442a (diff) |
use VirtualDevice in createHistorical8x8FromArray
part of making BitmapWriteAccess an internal detail of vcl/
Change-Id: I8b3aa2fdd3c26db0e48b228640cd31b0bd31543c
Reviewed-on: https://gerrit.libreoffice.org/49937
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | cui/source/tabpages/tppattern.cxx | 6 | ||||
-rw-r--r-- | include/svx/xbtmpit.hxx | 2 | ||||
-rw-r--r-- | svx/source/xoutdev/xattrbmp.cxx | 34 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabptrn.cxx | 2 |
4 files changed, 17 insertions, 27 deletions
diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx index 141bd052cc66..443f5d95f7f0 100644 --- a/cui/source/tabpages/tppattern.cxx +++ b/cui/source/tabpages/tppattern.cxx @@ -72,9 +72,9 @@ public: // BitmapCtl: Returns the Bitmap BitmapEx GetBitmapEx() { - const Bitmap aRetval(createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor)); - - return (pBmpArray != nullptr) ? BitmapEx(aRetval) : BitmapEx(); + if (!pBmpArray) + return BitmapEx(); + return createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor); } void SetBmpArray( const sal_uInt16* pPixel ) { pBmpArray = pPixel; } diff --git a/include/svx/xbtmpit.hxx b/include/svx/xbtmpit.hxx index 7f34b0c1be71..b9ced7c42fb0 100644 --- a/include/svx/xbtmpit.hxx +++ b/include/svx/xbtmpit.hxx @@ -30,7 +30,7 @@ class BitmapColor; // helper to construct historical 8x8 bitmaps with two colors -Bitmap SVX_DLLPUBLIC createHistorical8x8FromArray(const sal_uInt16* pArray, Color aColorPix, Color aColorBack); +BitmapEx SVX_DLLPUBLIC createHistorical8x8FromArray(sal_uInt16 const * pArray, Color aColorPix, Color aColorBack); bool SVX_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront); diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx index 8e6e5afb18a8..336f84d9c2a8 100644 --- a/svx/source/xoutdev/xattrbmp.cxx +++ b/svx/source/xoutdev/xattrbmp.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <vcl/salbtype.hxx> #include <vcl/bitmapaccess.hxx> +#include <vcl/BitmapTools.hxx> #include <vcl/dibtools.hxx> #include <libxml/xmlwriter.h> @@ -143,37 +144,26 @@ XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem) { } -Bitmap createHistorical8x8FromArray(const sal_uInt16* pArray, Color aColorPix, Color aColorBack) +BitmapEx createHistorical8x8FromArray(sal_uInt16 const *pArray, Color aColorPix, Color aColorBack) { - BitmapPalette aPalette(2); + vcl::bitmap::RawBitmap aBitmap(Size(8, 8)); - aPalette[0] = BitmapColor(aColorBack); - aPalette[1] = BitmapColor(aColorPix); - - Bitmap aBitmap(Size(8, 8), 1, &aPalette); - Bitmap::ScopedWriteAccess pContent(aBitmap); - - if(pContent) + for(sal_uInt16 a(0); a < 8; a++) { - for(sal_uInt16 a(0); a < 8; a++) + for(sal_uInt16 b(0); b < 8; b++) { - for(sal_uInt16 b(0); b < 8; b++) + if(pArray[(a * 8) + b]) { - if(pArray[(a * 8) + b]) - { - pContent->SetPixelIndex(a, b, 1); - } - else - { - pContent->SetPixelIndex(a, b, 0); - } + aBitmap.SetPixel(a, b, aColorBack); + } + else + { + aBitmap.SetPixel(a, b, aColorPix); } } - - pContent.reset(); } - return aBitmap; + return vcl::bitmap::CreateFromData(std::move(aBitmap)); } bool isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront) diff --git a/svx/source/xoutdev/xtabptrn.cxx b/svx/source/xoutdev/xtabptrn.cxx index 9dd126dd3126..40e38cb3e331 100644 --- a/svx/source/xoutdev/xtabptrn.cxx +++ b/svx/source/xoutdev/xtabptrn.cxx @@ -49,7 +49,7 @@ bool XPatternList::Create() { OUStringBuffer aStr(SvxResId(RID_SVXSTR_PATTERN)); sal_uInt16 aArray[64]; - Bitmap aBitmap; + BitmapEx aBitmap; const sal_Int32 nLen(aStr.getLength() - 1); memset(aArray, 0, sizeof(aArray)); |