summaryrefslogtreecommitdiff
path: root/vcl/source/bitmap
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-21 16:07:55 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-21 21:06:24 +0200
commitcd8dd48bf89d800c012afb04b16281ed8b261de9 (patch)
treece1ed337daefe46b0fd4f1e0f54dac629343b85d /vcl/source/bitmap
parentf05f4e042ca6ac8ae7f1d1e8e6bfb4cbba17a044 (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
Diffstat (limited to 'vcl/source/bitmap')
-rw-r--r--vcl/source/bitmap/BitmapTools.cxx65
1 files changed, 65 insertions, 0 deletions
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 4f13511a5fab..707b4c6b27b4 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -994,6 +994,71 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un
return aRes;
}
+ BitmapEx createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack)
+ {
+ BitmapPalette aPalette(2);
+
+ aPalette[0] = BitmapColor(aColorBack);
+ aPalette[1] = BitmapColor(aColorPix);
+
+ Bitmap aBitmap(Size(8, 8), 1, &aPalette);
+ BitmapWriteAccess* pContent(aBitmap.AcquireWriteAccess());
+
+ for(sal_uInt16 a(0); a < 8; a++)
+ {
+ for(sal_uInt16 b(0); b < 8; b++)
+ {
+ if(pArray[(a * 8) + b])
+ {
+ pContent->SetPixelIndex(a, b, 1);
+ }
+ else
+ {
+ pContent->SetPixelIndex(a, b, 0);
+ }
+ }
+ }
+
+ return BitmapEx(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;
+ }
+
}} // end vcl::bitmap
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */