summaryrefslogtreecommitdiffstats
path: root/vcl/inc/bitmap
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/inc/bitmap')
-rw-r--r--vcl/inc/bitmap/BitmapColorizeFilter.hxx30
-rw-r--r--vcl/inc/bitmap/BitmapDisabledImageFilter.hxx26
-rw-r--r--vcl/inc/bitmap/BitmapFastScaleFilter.hxx36
-rw-r--r--vcl/inc/bitmap/BitmapInterpolateScaleFilter.hxx35
-rw-r--r--vcl/inc/bitmap/BitmapLightenFilter.hxx24
-rw-r--r--vcl/inc/bitmap/BitmapMaskToAlphaFilter.hxx21
-rw-r--r--vcl/inc/bitmap/BitmapScaleConvolutionFilter.hxx78
-rw-r--r--vcl/inc/bitmap/BitmapScaleSuperFilter.hxx40
-rw-r--r--vcl/inc/bitmap/Octree.hxx83
-rw-r--r--vcl/inc/bitmap/ScanlineTools.hxx236
-rw-r--r--vcl/inc/bitmap/bmpfast.hxx51
-rw-r--r--vcl/inc/bitmap/impoctree.hxx110
12 files changed, 770 insertions, 0 deletions
diff --git a/vcl/inc/bitmap/BitmapColorizeFilter.hxx b/vcl/inc/bitmap/BitmapColorizeFilter.hxx
new file mode 100644
index 0000000000..ae511b322d
--- /dev/null
+++ b/vcl/inc/bitmap/BitmapColorizeFilter.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <tools/color.hxx>
+#include <vcl/BitmapFilter.hxx>
+
+class BitmapColorizeFilter final : public BitmapFilter
+{
+public:
+ BitmapColorizeFilter(Color aColor)
+ : maColor(aColor)
+ {
+ }
+
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override;
+
+private:
+ Color maColor;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/BitmapDisabledImageFilter.hxx b/vcl/inc/bitmap/BitmapDisabledImageFilter.hxx
new file mode 100644
index 0000000000..e1d9d21a9d
--- /dev/null
+++ b/vcl/inc/bitmap/BitmapDisabledImageFilter.hxx
@@ -0,0 +1,26 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_INC_BITMAP_BITMAPDISABLEDIMAGEFILTER_HXX
+#define INCLUDED_VCL_INC_BITMAP_BITMAPDISABLEDIMAGEFILTER_HXX
+
+#include <vcl/BitmapFilter.hxx>
+
+class VCL_DLLPUBLIC BitmapDisabledImageFilter final : public BitmapFilter
+{
+public:
+ BitmapDisabledImageFilter() {}
+
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/BitmapFastScaleFilter.hxx b/vcl/inc/bitmap/BitmapFastScaleFilter.hxx
new file mode 100644
index 0000000000..bea516c9e0
--- /dev/null
+++ b/vcl/inc/bitmap/BitmapFastScaleFilter.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef VCL_INC_BITMAP_BITMAPFASTSCALEFILTER_HXX
+#define VCL_INC_BITMAP_BITMAPFASTSCALEFILTER_HXX
+
+#include <vcl/bitmapex.hxx>
+#include <vcl/BitmapFilter.hxx>
+
+class BitmapFastScaleFilter final : public BitmapFilter
+{
+public:
+ explicit BitmapFastScaleFilter(double fScaleX, double fScaleY)
+ : mfScaleX(fScaleX)
+ , mfScaleY(fScaleY)
+ {
+ }
+
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override;
+
+private:
+ double mfScaleX;
+ double mfScaleY;
+ Size maSize;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/BitmapInterpolateScaleFilter.hxx b/vcl/inc/bitmap/BitmapInterpolateScaleFilter.hxx
new file mode 100644
index 0000000000..7d17c97d16
--- /dev/null
+++ b/vcl/inc/bitmap/BitmapInterpolateScaleFilter.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef VCL_INC_BITMAP_BITMAPINTERPOLATESCALEFILTER_HXX
+#define VCL_INC_BITMAP_BITMAPINTERPOLATESCALEFILTER_HXX
+
+#include <vcl/bitmapex.hxx>
+#include <vcl/BitmapFilter.hxx>
+
+class BitmapInterpolateScaleFilter final : public BitmapFilter
+{
+public:
+ explicit BitmapInterpolateScaleFilter(double fScaleX, double fScaleY)
+ : mfScaleX(fScaleX)
+ , mfScaleY(fScaleY)
+ {
+ }
+
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override;
+
+private:
+ double mfScaleX;
+ double mfScaleY;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/BitmapLightenFilter.hxx b/vcl/inc/bitmap/BitmapLightenFilter.hxx
new file mode 100644
index 0000000000..98f2493285
--- /dev/null
+++ b/vcl/inc/bitmap/BitmapLightenFilter.hxx
@@ -0,0 +1,24 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_INC_BITMAP_BITMAPLIGHTENFILTER_HXX
+#define INCLUDED_VCL_INC_BITMAP_BITMAPLIGHTENFILTER_HXX
+
+#include <vcl/BitmapFilter.hxx>
+
+class BitmapLightenFilter final : public BitmapFilter
+{
+public:
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/BitmapMaskToAlphaFilter.hxx b/vcl/inc/bitmap/BitmapMaskToAlphaFilter.hxx
new file mode 100644
index 0000000000..355d066846
--- /dev/null
+++ b/vcl/inc/bitmap/BitmapMaskToAlphaFilter.hxx
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <vcl/BitmapFilter.hxx>
+
+class BitmapMaskToAlphaFilter final : public BitmapFilter
+{
+public:
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/BitmapScaleConvolutionFilter.hxx b/vcl/inc/bitmap/BitmapScaleConvolutionFilter.hxx
new file mode 100644
index 0000000000..1c9bb8e330
--- /dev/null
+++ b/vcl/inc/bitmap/BitmapScaleConvolutionFilter.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef VCL_INC_BITMAP_BITMAPSCALECONVOLUTIONFILTER_HXX
+#define VCL_INC_BITMAP_BITMAPSCALECONVOLUTIONFILTER_HXX
+
+#include <vcl/BitmapFilter.hxx>
+
+#include <ResampleKernel.hxx>
+
+namespace vcl
+{
+class BitmapScaleConvolutionFilter : public BitmapFilter
+{
+protected:
+ BitmapScaleConvolutionFilter(const double& rScaleX, const double& rScaleY,
+ std::unique_ptr<Kernel> pKernel)
+ : mxKernel(std::move(pKernel))
+ , mrScaleX(rScaleX)
+ , mrScaleY(rScaleY)
+ {
+ }
+
+ virtual BitmapEx execute(BitmapEx const& rBitmap) const override;
+
+private:
+ std::unique_ptr<Kernel> mxKernel;
+ double mrScaleX;
+ double mrScaleY;
+};
+
+class VCL_DLLPUBLIC BitmapScaleBilinearFilter final : public BitmapScaleConvolutionFilter
+{
+public:
+ BitmapScaleBilinearFilter(const double& rScaleX, const double& rScaleY)
+ : BitmapScaleConvolutionFilter(rScaleX, rScaleY, std::make_unique<BilinearKernel>())
+ {
+ }
+};
+
+class VCL_DLLPUBLIC BitmapScaleBicubicFilter final : public BitmapScaleConvolutionFilter
+{
+public:
+ BitmapScaleBicubicFilter(const double& rScaleX, const double& rScaleY)
+ : BitmapScaleConvolutionFilter(rScaleX, rScaleY, std::make_unique<BicubicKernel>())
+ {
+ }
+};
+
+class VCL_DLLPUBLIC BitmapScaleLanczos3Filter final : public BitmapScaleConvolutionFilter
+{
+public:
+ BitmapScaleLanczos3Filter(const double& rScaleX, const double& rScaleY)
+ : BitmapScaleConvolutionFilter(rScaleX, rScaleY, std::make_unique<Lanczos3Kernel>())
+ {
+ }
+};
+}
+
+#endif // VCL_INC_BITMAPSCALECONVOLUTIONFILTER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/BitmapScaleSuperFilter.hxx b/vcl/inc/bitmap/BitmapScaleSuperFilter.hxx
new file mode 100644
index 0000000000..46c21d8d78
--- /dev/null
+++ b/vcl/inc/bitmap/BitmapScaleSuperFilter.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_BITMAP_BITMAPSCALESUPER_HXX
+#define INCLUDED_VCL_INC_BITMAP_BITMAPSCALESUPER_HXX
+
+#include <vcl/BitmapFilter.hxx>
+
+class BitmapScaleSuperFilter final : public BitmapFilter
+{
+public:
+ BitmapScaleSuperFilter(const double& rScaleX, const double& rScaleY);
+ virtual ~BitmapScaleSuperFilter() override;
+
+ virtual BitmapEx execute(BitmapEx const& rBitmap) const override;
+
+private:
+ double mrScaleX;
+ double mrScaleY;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/Octree.hxx b/vcl/inc/bitmap/Octree.hxx
new file mode 100644
index 0000000000..3c9b5eb270
--- /dev/null
+++ b/vcl/inc/bitmap/Octree.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_OCTREE_HXX
+#define INCLUDED_VCL_INC_OCTREE_HXX
+
+#include <vcl/dllapi.h>
+#include <vcl/BitmapColor.hxx>
+#include <vcl/BitmapPalette.hxx>
+#include <tools/solar.h>
+
+struct OctreeNode
+{
+ sal_uLong nCount = 0;
+ sal_uLong nRed = 0;
+ sal_uLong nGreen = 0;
+ sal_uLong nBlue = 0;
+ std::unique_ptr<OctreeNode> pChild[8];
+ OctreeNode* pNext = nullptr;
+ sal_uInt16 nPalIndex = 0;
+ bool bLeaf = false;
+};
+
+class BitmapReadAccess;
+
+class VCL_PLUGIN_PUBLIC Octree
+{
+private:
+ void CreatePalette(OctreeNode* pNode);
+ void GetPalIndex(const OctreeNode* pNode, BitmapColor const& color);
+
+ SAL_DLLPRIVATE void add(std::unique_ptr<OctreeNode>& rpNode, BitmapColor const& color);
+ SAL_DLLPRIVATE void reduce();
+
+ BitmapPalette maPalette;
+ sal_uLong mnLeafCount;
+ sal_uLong mnLevel;
+ std::unique_ptr<OctreeNode> pTree;
+ std::vector<OctreeNode*> mpReduce;
+ sal_uInt16 mnPalIndex;
+
+public:
+ Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors);
+ ~Octree();
+
+ const BitmapPalette& GetPalette();
+ sal_uInt16 GetBestPaletteIndex(const BitmapColor& rColor);
+};
+
+class InverseColorMap
+{
+private:
+ std::vector<sal_uInt8> mpBuffer;
+ std::vector<sal_uInt8> mpMap;
+
+ void ImplCreateBuffers();
+
+public:
+ explicit InverseColorMap(const BitmapPalette& rPal);
+ ~InverseColorMap();
+
+ sal_uInt16 GetBestPaletteIndex(const BitmapColor& rColor);
+};
+
+#endif // INCLUDED_VCL_INC_OCTREE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/ScanlineTools.hxx b/vcl/inc/bitmap/ScanlineTools.hxx
new file mode 100644
index 0000000000..99ce5dc33a
--- /dev/null
+++ b/vcl/inc/bitmap/ScanlineTools.hxx
@@ -0,0 +1,236 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_INC_BITMAP_SCANLINETOOLS_HXX
+#define INCLUDED_VCL_INC_BITMAP_SCANLINETOOLS_HXX
+
+#include <tools/color.hxx>
+#include <vcl/BitmapPalette.hxx>
+
+namespace vcl::bitmap
+{
+class ScanlineTransformer
+{
+public:
+ virtual void startLine(sal_uInt8* pLine) = 0;
+ virtual void skipPixel(sal_uInt32 nPixel) = 0;
+ virtual Color readPixel() = 0;
+ virtual void writePixel(Color nColor) = 0;
+
+ virtual ~ScanlineTransformer() = default;
+};
+
+class ScanlineTransformer_ARGB final : public ScanlineTransformer
+{
+private:
+ sal_uInt8* pData;
+
+public:
+ virtual void startLine(sal_uInt8* pLine) override { pData = pLine; }
+
+ virtual void skipPixel(sal_uInt32 nPixel) override { pData += nPixel << 2; }
+
+ virtual Color readPixel() override
+ {
+ const Color aColor(ColorAlpha, pData[4], pData[1], pData[2], pData[3]);
+ pData += 4;
+ return aColor;
+ }
+
+ virtual void writePixel(Color nColor) override
+ {
+ *pData++ = nColor.GetAlpha();
+ *pData++ = nColor.GetRed();
+ *pData++ = nColor.GetGreen();
+ *pData++ = nColor.GetBlue();
+ }
+};
+
+class ScanlineTransformer_BGR final : public ScanlineTransformer
+{
+private:
+ sal_uInt8* pData;
+
+public:
+ virtual void startLine(sal_uInt8* pLine) override { pData = pLine; }
+
+ virtual void skipPixel(sal_uInt32 nPixel) override { pData += (nPixel << 1) + nPixel; }
+
+ virtual Color readPixel() override
+ {
+ const Color aColor(pData[2], pData[1], pData[0]);
+ pData += 3;
+ return aColor;
+ }
+
+ virtual void writePixel(Color nColor) override
+ {
+ *pData++ = nColor.GetBlue();
+ *pData++ = nColor.GetGreen();
+ *pData++ = nColor.GetRed();
+ }
+};
+
+class ScanlineTransformer_8BitPalette final : public ScanlineTransformer
+{
+private:
+ sal_uInt8* pData;
+ const BitmapPalette& mrPalette;
+
+public:
+ explicit ScanlineTransformer_8BitPalette(const BitmapPalette& rPalette)
+ : pData(nullptr)
+ , mrPalette(rPalette)
+ {
+ }
+
+ virtual void startLine(sal_uInt8* pLine) override { pData = pLine; }
+
+ virtual void skipPixel(sal_uInt32 nPixel) override { pData += nPixel; }
+
+ virtual Color readPixel() override
+ {
+ const sal_uInt8 nIndex(*pData++);
+ if (nIndex < mrPalette.GetEntryCount())
+ return mrPalette[nIndex];
+ else
+ return COL_BLACK;
+ }
+
+ virtual void writePixel(Color nColor) override
+ {
+ *pData++ = static_cast<sal_uInt8>(mrPalette.GetBestIndex(nColor));
+ }
+};
+
+class ScanlineTransformer_4BitPalette final : public ScanlineTransformer
+{
+private:
+ sal_uInt8* pData;
+ const BitmapPalette& mrPalette;
+ sal_uInt32 mnX;
+ sal_uInt32 mnShift;
+
+public:
+ explicit ScanlineTransformer_4BitPalette(const BitmapPalette& rPalette)
+ : pData(nullptr)
+ , mrPalette(rPalette)
+ , mnX(0)
+ , mnShift(0)
+ {
+ }
+
+ virtual void skipPixel(sal_uInt32 nPixel) override
+ {
+ mnX += nPixel;
+ if (nPixel & 1) // is nPixel an odd number
+ mnShift ^= 4;
+ }
+
+ virtual void startLine(sal_uInt8* pLine) override
+ {
+ pData = pLine;
+ mnX = 0;
+ mnShift = 4;
+ }
+
+ virtual Color readPixel() override
+ {
+ const sal_uInt32 nDataIndex = mnX / 2;
+ const sal_uInt8 nIndex((pData[nDataIndex] >> mnShift) & 0x0f);
+ mnX++;
+ mnShift ^= 4;
+
+ if (nIndex < mrPalette.GetEntryCount())
+ return mrPalette[nIndex];
+ else
+ return COL_BLACK;
+ }
+
+ virtual void writePixel(Color nColor) override
+ {
+ const sal_uInt32 nDataIndex = mnX / 2;
+ const sal_uInt8 nColorIndex = mrPalette.GetBestIndex(nColor);
+ pData[nDataIndex] |= (nColorIndex & 0x0f) << mnShift;
+ mnX++;
+ mnShift ^= 4;
+ }
+};
+
+class ScanlineTransformer_1BitPalette final : public ScanlineTransformer
+{
+private:
+ sal_uInt8* pData;
+ const BitmapPalette& mrPalette;
+ sal_uInt32 mnX;
+
+public:
+ explicit ScanlineTransformer_1BitPalette(const BitmapPalette& rPalette)
+ : pData(nullptr)
+ , mrPalette(rPalette)
+ , mnX(0)
+ {
+ }
+
+ virtual void skipPixel(sal_uInt32 nPixel) override { mnX += nPixel; }
+
+ virtual void startLine(sal_uInt8* pLine) override
+ {
+ pData = pLine;
+ mnX = 0;
+ }
+
+ virtual Color readPixel() override
+ {
+ const sal_uInt8 nIndex((pData[mnX >> 3] >> (7 - (mnX & 7))) & 1);
+ mnX++;
+
+ if (nIndex < mrPalette.GetEntryCount())
+ return mrPalette[nIndex];
+ else
+ return COL_BLACK;
+ }
+
+ virtual void writePixel(Color nColor) override
+ {
+ if (mrPalette.GetBestIndex(nColor) & 1)
+ pData[mnX >> 3] |= 1 << (7 - (mnX & 7));
+ else
+ pData[mnX >> 3] &= ~(1 << (7 - (mnX & 7)));
+ mnX++;
+ }
+};
+
+std::unique_ptr<ScanlineTransformer> getScanlineTransformer(sal_uInt16 nBits,
+ const BitmapPalette& rPalette)
+{
+ switch (nBits)
+ {
+ case 1:
+ return std::make_unique<ScanlineTransformer_1BitPalette>(rPalette);
+ case 4:
+ return std::make_unique<ScanlineTransformer_4BitPalette>(rPalette);
+ case 8:
+ return std::make_unique<ScanlineTransformer_8BitPalette>(rPalette);
+ case 24:
+ return std::make_unique<ScanlineTransformer_BGR>();
+ case 32:
+ return std::make_unique<ScanlineTransformer_ARGB>();
+ default:
+ assert(false);
+ break;
+ }
+ return nullptr;
+}
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/bmpfast.hxx b/vcl/inc/bitmap/bmpfast.hxx
new file mode 100644
index 0000000000..3234f7a840
--- /dev/null
+++ b/vcl/inc/bitmap/bmpfast.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_BMPFAST_HXX
+#define INCLUDED_VCL_INC_BMPFAST_HXX
+
+#include <vcl/dllapi.h>
+#include <vcl/Scanline.hxx>
+#include <tools/long.hxx>
+
+class BitmapWriteAccess;
+class BitmapReadAccess;
+struct BitmapBuffer;
+class BitmapColor;
+struct SalTwoRect;
+
+// the bmpfast functions have signatures with good compatibility to
+// their canonic counterparts, which employ the GetPixel/SetPixel methods
+
+VCL_DLLPUBLIC bool ImplFastBitmapConversion( BitmapBuffer& rDst, const BitmapBuffer& rSrc,
+ const SalTwoRect& rTwoRect );
+
+bool ImplFastCopyScanline( tools::Long nY, BitmapBuffer& rDst, const BitmapBuffer& rSrc);
+bool ImplFastCopyScanline( tools::Long nY, BitmapBuffer& rDst, ConstScanline aSrcScanline,
+ ScanlineFormat nSrcScanlineFormat, sal_uInt32 nSrcScanlineSize);
+
+bool ImplFastBitmapBlending( BitmapWriteAccess const & rDst,
+ const BitmapReadAccess& rSrc, const BitmapReadAccess& rMask,
+ const SalTwoRect& rTwoRect );
+
+bool ImplFastEraseBitmap( BitmapBuffer&, const BitmapColor& );
+
+#endif // INCLUDED_VCL_INC_BMPFAST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmap/impoctree.hxx b/vcl/inc/bitmap/impoctree.hxx
new file mode 100644
index 0000000000..7581b91088
--- /dev/null
+++ b/vcl/inc/bitmap/impoctree.hxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_INC_IMPOCTREE_HXX
+#define INCLUDED_VCL_INC_IMPOCTREE_HXX
+
+#include <vcl/BitmapColor.hxx>
+
+class ImpErrorQuad
+{
+ sal_Int16 nRed;
+ sal_Int16 nGreen;
+ sal_Int16 nBlue;
+
+public:
+ ImpErrorQuad()
+ : nRed(0)
+ , nGreen(0)
+ , nBlue(0)
+ {
+ }
+
+ ImpErrorQuad(const BitmapColor& rColor)
+ : nRed(rColor.GetRed() << 5)
+ , nGreen(rColor.GetGreen() << 5)
+ , nBlue(rColor.GetBlue() << 5)
+ {
+ }
+
+ inline void operator=(const BitmapColor& rColor);
+ inline ImpErrorQuad& operator-=(const BitmapColor& rColor);
+
+ inline void ImplAddColorError1(const ImpErrorQuad& rErrQuad);
+ inline void ImplAddColorError3(const ImpErrorQuad& rErrQuad);
+ inline void ImplAddColorError5(const ImpErrorQuad& rErrQuad);
+ inline void ImplAddColorError7(const ImpErrorQuad& rErrQuad);
+
+ inline BitmapColor ImplGetColor() const;
+};
+
+inline void ImpErrorQuad::operator=(const BitmapColor& rColor)
+{
+ nRed = rColor.GetRed() << 5;
+ nGreen = rColor.GetGreen() << 5;
+ nBlue = rColor.GetBlue() << 5;
+}
+
+inline ImpErrorQuad& ImpErrorQuad::operator-=(const BitmapColor& rColor)
+{
+ nRed -= rColor.GetRed() << 5;
+ nGreen -= rColor.GetGreen() << 5;
+ nBlue -= rColor.GetBlue() << 5;
+
+ return *this;
+}
+
+inline void ImpErrorQuad::ImplAddColorError1(const ImpErrorQuad& rErrQuad)
+{
+ nRed += rErrQuad.nRed >> 4;
+ nGreen += rErrQuad.nGreen >> 4;
+ nBlue += rErrQuad.nBlue >> 4;
+}
+
+inline void ImpErrorQuad::ImplAddColorError3(const ImpErrorQuad& rErrQuad)
+{
+ nRed += rErrQuad.nRed * 3L >> 4;
+ nGreen += rErrQuad.nGreen * 3L >> 4;
+ nBlue += rErrQuad.nBlue * 3L >> 4;
+}
+
+inline void ImpErrorQuad::ImplAddColorError5(const ImpErrorQuad& rErrQuad)
+{
+ nRed += rErrQuad.nRed * 5L >> 4;
+ nGreen += rErrQuad.nGreen * 5L >> 4;
+ nBlue += rErrQuad.nBlue * 5L >> 4;
+}
+
+inline void ImpErrorQuad::ImplAddColorError7(const ImpErrorQuad& rErrQuad)
+{
+ nRed += rErrQuad.nRed * 7L >> 4;
+ nGreen += rErrQuad.nGreen * 7L >> 4;
+ nBlue += rErrQuad.nBlue * 7L >> 4;
+}
+
+inline BitmapColor ImpErrorQuad::ImplGetColor() const
+{
+ return BitmapColor(std::clamp(nRed, sal_Int16(0), sal_Int16(8160)) >> 5,
+ std::clamp(nGreen, sal_Int16(0), sal_Int16(8160)) >> 5,
+ std::clamp(nBlue, sal_Int16(0), sal_Int16(8160)) >> 5);
+}
+
+#endif // INCLUDED_VCL_INC_IMPOCTREE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */