diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-21 16:07:55 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-08-23 16:41:59 +0200 |
commit | 7607320e8e68cfeb2ef8933d8a5a7d06f74f16fd (patch) | |
tree | b4b4ae5ea6bd6ec2ce1d252442351a8e2ad2d52f /svx | |
parent | 88897b74118fa6d269ce325aca6a4ac3ac1ae3de (diff) |
tdf#119282 Area tab, Pattern color change
regression from
commit ccd316d1cb310734848bd20244f509024b549b8c
use VirtualDevice in createHistorical8x8FromArray
Move the code inside vcl so we don't need to expose BitmapWriteAccess.
I tried to detect this thing by counting the number of independent
colors in the bitmap, but that didn't work. It is used from more than
one place, and appears to be very determined that it needs a 2-color
palette to work properly.
Change-Id: Id11dd9ea78e5e522a6083d6a799e801cac81fd5b
Reviewed-on: https://gerrit.libreoffice.org/59331
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins
(cherry picked from commit cd8dd48bf89d800c012afb04b16281ed8b261de9)
Reviewed-on: https://gerrit.libreoffice.org/59416
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/dlgctrl.cxx | 3 | ||||
-rw-r--r-- | svx/source/xoutdev/xattrbmp.cxx | 61 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabptrn.cxx | 9 |
3 files changed, 8 insertions, 65 deletions
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index 48a24c0372f5..f5ec3b570d93 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -46,6 +46,7 @@ #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> #include <svx/sdr/contact/displayinfo.hxx> #include <vcl/bitmapaccess.hxx> +#include <vcl/BitmapTools.hxx> #include <svx/xbtmpit.hxx> #define OUTPUT_DRAWMODE_COLOR (DrawModeFlags::Default) @@ -1445,7 +1446,7 @@ void SvxPixelCtl::SetXBitmap(const BitmapEx& rBitmapEx) BitmapColor aBack; BitmapColor aFront; - if (isHistorical8x8(rBitmapEx, aBack, aFront)) + if (vcl::bitmap::isHistorical8x8(rBitmapEx, aBack, aFront)) { Bitmap aBitmap(rBitmapEx.GetBitmap()); Bitmap::ScopedReadAccess pRead(aBitmap); diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx index a25c5d41faf4..b20bbf4d5ec8 100644 --- a/svx/source/xoutdev/xattrbmp.cxx +++ b/svx/source/xoutdev/xattrbmp.cxx @@ -144,65 +144,6 @@ XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem) { } -BitmapEx createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack) -{ - vcl::bitmap::RawBitmap aBitmap(Size(8, 8), 24); - - for(sal_uInt16 a(0); a < 8; a++) - { - for(sal_uInt16 b(0); b < 8; b++) - { - if(pArray[(a * 8) + b]) - { - aBitmap.SetPixel(a, b, aColorBack); - } - else - { - aBitmap.SetPixel(a, b, aColorPix); - } - } - } - - return vcl::bitmap::CreateFromData(std::move(aBitmap)); -} - -bool isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront) -{ - bool bRet(false); - - if(!rBitmapEx.IsTransparent()) - { - Bitmap aBitmap(rBitmapEx.GetBitmap()); - - if(8 == aBitmap.GetSizePixel().Width() && 8 == aBitmap.GetSizePixel().Height()) - { - if(2 == aBitmap.GetColorCount()) - { - BitmapReadAccess* pRead = aBitmap.AcquireReadAccess(); - - if(pRead) - { - if(pRead->HasPalette() && 2 == pRead->GetPaletteEntryCount()) - { - const BitmapPalette& rPalette = pRead->GetPalette(); - - // #i123564# background and foreground were exchanged; of course - // rPalette[0] is the background color - o_rFront = rPalette[1]; - o_rBack = rPalette[0]; - - bRet = true; - } - - Bitmap::ReleaseAccess(pRead); - } - } - } - } - - return bRet; -} - XFillBitmapItem::XFillBitmapItem(const GraphicObject& rGraphicObject) : NameOrIndex(XATTR_FILLBITMAP, -1) , maGraphicObject(rGraphicObject) @@ -224,7 +165,7 @@ bool XFillBitmapItem::operator==(const SfxPoolItem& rItem) const bool XFillBitmapItem::isPattern() const { BitmapColor aBack, aFront; - return isHistorical8x8(GetGraphicObject().GetGraphic().GetBitmapEx(), aBack, aFront); + return vcl::bitmap::isHistorical8x8(GetGraphicObject().GetGraphic().GetBitmapEx(), aBack, aFront); } sal_uInt16 XFillBitmapItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const diff --git a/svx/source/xoutdev/xtabptrn.cxx b/svx/source/xoutdev/xtabptrn.cxx index ff9fc20f3471..d156b28c5190 100644 --- a/svx/source/xoutdev/xtabptrn.cxx +++ b/svx/source/xoutdev/xtabptrn.cxx @@ -29,6 +29,7 @@ #include <svx/xbtmpit.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> +#include <vcl/BitmapTools.hxx> #include <o3tl/make_unique.hxx> @@ -56,28 +57,28 @@ bool XPatternList::Create() // white/white bitmap aStr.append(" 1"); - aBitmap = createHistorical8x8FromArray(aArray, COL_WHITE, COL_WHITE); + aBitmap = vcl::bitmap::createHistorical8x8FromArray(aArray, COL_WHITE, COL_WHITE); Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString())); // black/white bitmap aArray[ 0] = 1; aArray[ 9] = 1; aArray[18] = 1; aArray[27] = 1; aArray[36] = 1; aArray[45] = 1; aArray[54] = 1; aArray[63] = 1; aStr[nLen] = '2'; - aBitmap = createHistorical8x8FromArray(aArray, COL_BLACK, COL_WHITE); + aBitmap = vcl::bitmap::createHistorical8x8FromArray(aArray, COL_BLACK, COL_WHITE); Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString())); // lightred/white bitmap aArray[ 7] = 1; aArray[14] = 1; aArray[21] = 1; aArray[28] = 1; aArray[35] = 1; aArray[42] = 1; aArray[49] = 1; aArray[56] = 1; aStr[nLen] = '3'; - aBitmap = createHistorical8x8FromArray(aArray, COL_LIGHTRED, COL_WHITE); + aBitmap = vcl::bitmap::createHistorical8x8FromArray(aArray, COL_LIGHTRED, COL_WHITE); Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString())); // lightblue/white bitmap aArray[24] = 1; aArray[25] = 1; aArray[26] = 1; aArray[29] = 1; aArray[30] = 1; aArray[31] = 1; aStr[nLen] = '4'; - aBitmap = createHistorical8x8FromArray(aArray, COL_LIGHTBLUE, COL_WHITE); + aBitmap = vcl::bitmap::createHistorical8x8FromArray(aArray, COL_LIGHTBLUE, COL_WHITE); Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString())); return true; |