summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cui/source/tabpages/tppattern.cxx5
-rw-r--r--include/svx/xbtmpit.hxx6
-rw-r--r--include/vcl/BitmapTools.hxx6
-rw-r--r--svx/source/dialog/dlgctrl.cxx3
-rw-r--r--svx/source/xoutdev/xattrbmp.cxx61
-rw-r--r--svx/source/xoutdev/xtabptrn.cxx9
-rw-r--r--vcl/source/bitmap/BitmapTools.cxx65
7 files changed, 82 insertions, 73 deletions
diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx
index 7d864da0326f..a696204da30e 100644
--- a/cui/source/tabpages/tppattern.cxx
+++ b/cui/source/tabpages/tppattern.cxx
@@ -29,6 +29,7 @@
#include <svx/colorbox.hxx>
#include <svx/dialmgr.hxx>
#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapTools.hxx>
#include <vcl/settings.hxx>
#include <vcl/weld.hxx>
#include <svx/dialogs.hrc>
@@ -74,7 +75,7 @@ public:
{
if (!pBmpArray)
return BitmapEx();
- return createHistorical8x8FromArray(*pBmpArray, aPixelColor, aBackgroundColor);
+ return vcl::bitmap::createHistorical8x8FromArray(*pBmpArray, aPixelColor, aBackgroundColor);
}
void SetBmpArray( std::array<sal_uInt8,64> const & pPixel ) { pBmpArray = &pPixel; }
@@ -296,7 +297,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, ValueSet*, void)
{
BitmapColor aBack;
BitmapColor aFront;
- bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmapEx(), aBack, aFront));
+ bool bIs8x8(vcl::bitmap::isHistorical8x8(pGraphicObject->GetGraphic().GetBitmapEx(), aBack, aFront));
m_pLbColor->SetNoSelection();
m_pLbBackgroundColor->SetNoSelection();
diff --git a/include/svx/xbtmpit.hxx b/include/svx/xbtmpit.hxx
index 2f8e5f1181ee..218985c077d6 100644
--- a/include/svx/xbtmpit.hxx
+++ b/include/svx/xbtmpit.hxx
@@ -29,12 +29,6 @@ class SdrModel;
class BitmapColor;
-// helper to construct historical 8x8 bitmaps with two colors
-
-BitmapEx SVX_DLLPUBLIC createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack);
-bool SVX_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront);
-
-
// class XFillBitmapItem
class SVX_DLLPUBLIC XFillBitmapItem : public NameOrIndex
diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx
index 2064cb2d01dc..75eb6ed53077 100644
--- a/include/vcl/BitmapTools.hxx
+++ b/include/vcl/BitmapTools.hxx
@@ -23,6 +23,7 @@
#include <basegfx/range/b2drectangle.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <o3tl/safeint.hxx>
+#include <array>
namespace vcl {
namespace bitmap {
@@ -113,6 +114,11 @@ VCL_DLLPUBLIC void CanvasCairoExtractBitmapData( BitmapEx const & rBmpEx, Bitmap
VCL_DLLPUBLIC css::uno::Sequence< sal_Int8 > CanvasExtractBitmapData(BitmapEx const & rBitmapEx, const css::geometry::IntegerRectangle2D& rect);
+// helper to construct historical 8x8 bitmaps with two colors
+
+BitmapEx VCL_DLLPUBLIC createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack);
+bool VCL_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront);
+
}} // end vcl::bitmap
#endif // INCLUDED_VCL_BITMAP_TOOLS_HXX
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index 6f757f1ec62b..659a572ba369 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)
@@ -1442,7 +1443,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 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<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 853fd24a819e..d207bb15de4c 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;
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: */