From cd8dd48bf89d800c012afb04b16281ed8b261de9 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 21 Aug 2018 16:07:55 +0200 Subject: 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 Tested-by: Jenkins --- svx/source/xoutdev/xattrbmp.cxx | 61 +---------------------------------------- 1 file changed, 1 insertion(+), 60 deletions(-) (limited to 'svx/source/xoutdev/xattrbmp.cxx') diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx index 2e9269857935..262870a8ad8b 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 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 -- cgit