summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/BitmapFilter.hxx (renamed from vcl/inc/bitmapfilter.hxx)12
-rw-r--r--solenv/clang-format/blacklist8
-rw-r--r--vcl/Library_vcl.mk8
-rw-r--r--vcl/inc/BitmapColorizeFilter.hxx34
-rw-r--r--vcl/inc/BitmapDisabledImageFilter.hxx (renamed from vcl/inc/BitmapProcessor.hxx)17
-rw-r--r--vcl/inc/BitmapLightenFilter.hxx24
-rwxr-xr-x[-rw-r--r--]vcl/inc/BitmapScaleConvolutionFilter.hxx (renamed from vcl/inc/BitmapScaleConvolution.hxx)60
-rw-r--r--vcl/inc/BitmapScaleSuperFilter.hxx (renamed from vcl/inc/bitmapscalesuper.hxx)12
-rw-r--r--vcl/qa/cppunit/BitmapProcessorTest.cxx7
-rw-r--r--vcl/source/bitmap/BitmapColorizeFilter.cxx94
-rw-r--r--vcl/source/bitmap/BitmapDisabledImageFilter.cxx107
-rw-r--r--vcl/source/bitmap/BitmapLightenFilter.cxx68
-rw-r--r--vcl/source/bitmap/BitmapProcessor.cxx220
-rwxr-xr-x[-rw-r--r--]vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx (renamed from vcl/source/bitmap/BitmapScaleConvolution.cxx)30
-rwxr-xr-x[-rw-r--r--]vcl/source/bitmap/BitmapScaleSuperFilter.cxx (renamed from vcl/source/bitmap/bitmapscalesuper.cxx)200
-rw-r--r--vcl/source/bitmap/bitmapfilter.cxx16
-rwxr-xr-x[-rw-r--r--]vcl/source/gdi/bitmap3.cxx91
-rw-r--r--vcl/source/gdi/bitmapex.cxx12
-rw-r--r--vcl/source/image/Image.cxx10
-rw-r--r--vcl/source/image/ImplImageTree.cxx8
20 files changed, 597 insertions, 441 deletions
diff --git a/vcl/inc/bitmapfilter.hxx b/include/vcl/BitmapFilter.hxx
index 82f5f2edf091..f8759a1302c2 100644
--- a/vcl/inc/bitmapfilter.hxx
+++ b/include/vcl/BitmapFilter.hxx
@@ -11,15 +11,17 @@
#ifndef INCLUDED_VCL_INC_BITMAPFILTER_HXX
#define INCLUDED_VCL_INC_BITMAPFILTER_HXX
-#include <vcl/bitmap.hxx>
+#include <vcl/bitmapex.hxx>
-class BitmapFilter
+class VCL_DLLPUBLIC BitmapFilter
{
public:
- BitmapFilter();
- virtual ~BitmapFilter();
+ BitmapFilter();
+ virtual ~BitmapFilter();
- virtual bool execute(Bitmap& rBitmap) = 0;
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) = 0;
+
+ static bool Filter(BitmapEx& rBmpEx, BitmapFilter&& rFilter);
};
#endif
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 91618660943c..277911b2b46d 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -17546,7 +17546,8 @@ vcl/headless/svpprn.cxx
vcl/headless/svptext.cxx
vcl/headless/svpvd.cxx
vcl/inc/BitmapProcessor.hxx
-vcl/inc/BitmapScaleConvolution.hxx
+vcl/inc/BitmapScaleConvolutionFilter.hxx
+vcl/inc/BitmapScaleSuperFilter.hxx
vcl/inc/BitmapSymmetryCheck.hxx
vcl/inc/CommonSalLayout.hxx
vcl/inc/ControlCacheKey.hxx
@@ -17559,7 +17560,6 @@ vcl/inc/accmgr.hxx
vcl/inc/android/androidinst.hxx
vcl/inc/android/svsys.h
vcl/inc/bitmapfilter.hxx
-vcl/inc/bitmapscalesuper.hxx
vcl/inc/bmpfast.hxx
vcl/inc/brdwin.hxx
vcl/inc/canvasbitmap.hxx
@@ -18038,12 +18038,12 @@ vcl/source/app/unohelp.cxx
vcl/source/app/unohelp2.cxx
vcl/source/app/vclevent.cxx
vcl/source/bitmap/BitmapProcessor.cxx
-vcl/source/bitmap/BitmapScaleConvolution.cxx
+vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
+vcl/source/bitmap/BitmapScaleSuperFilter.cxx
vcl/source/bitmap/BitmapSymmetryCheck.cxx
vcl/source/bitmap/BitmapTools.cxx
vcl/source/bitmap/bitmap.cxx
vcl/source/bitmap/bitmapfilter.cxx
-vcl/source/bitmap/bitmapscalesuper.cxx
vcl/source/bitmap/checksum.cxx
vcl/source/components/dtranscomp.cxx
vcl/source/components/factory.cxx
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index c854e94bad45..3a819cefab26 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -313,11 +313,13 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/graphic/UnoGraphicTransformer \
vcl/source/bitmap/bitmap \
vcl/source/bitmap/bitmapfilter \
+ vcl/source/bitmap/BitmapLightenFilter \
+ vcl/source/bitmap/BitmapDisabledImageFilter \
+ vcl/source/bitmap/BitmapColorizeFilter \
vcl/source/bitmap/bitmappaint \
- vcl/source/bitmap/bitmapscalesuper \
- vcl/source/bitmap/BitmapScaleConvolution \
+ vcl/source/bitmap/BitmapScaleSuperFilter \
+ vcl/source/bitmap/BitmapScaleConvolutionFilter \
vcl/source/bitmap/BitmapSymmetryCheck \
- vcl/source/bitmap/BitmapProcessor \
vcl/source/bitmap/BitmapTools \
vcl/source/bitmap/checksum \
vcl/source/image/Image \
diff --git a/vcl/inc/BitmapColorizeFilter.hxx b/vcl/inc/BitmapColorizeFilter.hxx
new file mode 100644
index 000000000000..0fac997d5f10
--- /dev/null
+++ b/vcl/inc/BitmapColorizeFilter.hxx
@@ -0,0 +1,34 @@
+/* -*- 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_BITMAPCOLORIZEFILTER_HXX
+#define INCLUDED_VCL_INC_BITMAPCOLORIZEFILTER_HXX
+
+#include <tools/color.hxx>
+
+#include <vcl/BitmapFilter.hxx>
+
+class VCL_DLLPUBLIC BitmapColorizeFilter : public BitmapFilter
+{
+public:
+ BitmapColorizeFilter(Color aColor)
+ : maColor(aColor)
+ {
+ }
+
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) override;
+
+private:
+ Color maColor;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/BitmapProcessor.hxx b/vcl/inc/BitmapDisabledImageFilter.hxx
index 5f5bd8b69b6c..2f69e8fa0c51 100644
--- a/vcl/inc/BitmapProcessor.hxx
+++ b/vcl/inc/BitmapDisabledImageFilter.hxx
@@ -5,21 +5,22 @@
* 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_PROCESSOR_HXX
-#define VCL_INC_BITMAP_PROCESSOR_HXX
+#ifndef INCLUDED_VCL_INC_BITMAPDISABLEDIMAGEFILTER_HXX
+#define INCLUDED_VCL_INC_BITMAPDISABLEDIMAGEFILTER_HXX
-#include <vcl/bitmapex.hxx>
+#include <vcl/BitmapFilter.hxx>
-class VCL_DLLPUBLIC BitmapProcessor
+class VCL_DLLPUBLIC BitmapDisabledImageFilter : public BitmapFilter
{
public:
- static BitmapEx createLightImage(const BitmapEx& rBitmapEx);
- static BitmapEx createDisabledImage(const BitmapEx& rBitmapEx);
- static void colorizeImage(BitmapEx const & rBitmapEx, Color aColor);
+ BitmapDisabledImageFilter() {}
+
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) override;
};
-#endif // VCL_INC_BITMAP_PROCESSOR_HXX
+#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/BitmapLightenFilter.hxx b/vcl/inc/BitmapLightenFilter.hxx
new file mode 100644
index 000000000000..ffd8ede55574
--- /dev/null
+++ b/vcl/inc/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_BITMAPLIGHTENFILTER_HXX
+#define INCLUDED_VCL_INC_BITMAPLIGHTENFILTER_HXX
+
+#include <vcl/BitmapFilter.hxx>
+
+class VCL_DLLPUBLIC BitmapLightenFilter : public BitmapFilter
+{
+public:
+ virtual BitmapEx execute(BitmapEx const& rBitmapEx) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/BitmapScaleConvolution.hxx b/vcl/inc/BitmapScaleConvolutionFilter.hxx
index 60e450f670ba..9a0c5dafbb04 100644..100755
--- a/vcl/inc/BitmapScaleConvolution.hxx
+++ b/vcl/inc/BitmapScaleConvolutionFilter.hxx
@@ -17,42 +17,66 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_VCL_BITMAPSCALECONVOLUTION_HXX
-#define INCLUDED_VCL_BITMAPSCALECONVOLUTION_HXX
+#ifndef VCL_INC_BITMAPSCALECONVOLUTIONFILTER_HXX
+#define VCL_INC_BITMAPSCALECONVOLUTIONFILTER_HXX
-#include "bitmapfilter.hxx"
+#include <vcl/BitmapFilter.hxx>
-namespace vcl
-{
+#include "ResampleKernel.hxx"
-enum class ConvolutionKernelType
+namespace vcl
{
- BiLinear = 1,
- BiCubic = 2,
- Lanczos3 = 3,
-};
-
class VCL_DLLPUBLIC BitmapScaleConvolutionFilter : public BitmapFilter
{
public:
-
- BitmapScaleConvolutionFilter(const double& rScaleX, const double& rScaleY, ConvolutionKernelType eKernelType)
+ BitmapScaleConvolutionFilter(const double& rScaleX, const double& rScaleY)
: mrScaleX(rScaleX)
, mrScaleY(rScaleY)
- , meKernelType(eKernelType)
- {}
+ {
+ }
+
+ virtual BitmapEx execute(BitmapEx const& rBitmap) override;
- virtual bool execute(Bitmap& rBitmap) override;
+protected:
+ Kernel* mpKernel;
private:
double mrScaleX;
double mrScaleY;
+};
+
+class VCL_DLLPUBLIC BitmapScaleBilinearFilter : public BitmapScaleConvolutionFilter
+{
+public:
+ BitmapScaleBilinearFilter(const double& rScaleX, const double& rScaleY)
+ : BitmapScaleConvolutionFilter(rScaleX, rScaleY)
+ {
+ mpKernel = new BilinearKernel();
+ }
+};
- ConvolutionKernelType meKernelType;
+class VCL_DLLPUBLIC BitmapScaleBicubicFilter : public BitmapScaleConvolutionFilter
+{
+public:
+ BitmapScaleBicubicFilter(const double& rScaleX, const double& rScaleY)
+ : BitmapScaleConvolutionFilter(rScaleX, rScaleY)
+ {
+ mpKernel = new BicubicKernel();
+ }
+};
+
+class VCL_DLLPUBLIC BitmapScaleLanczos3Filter : public BitmapScaleConvolutionFilter
+{
+public:
+ BitmapScaleLanczos3Filter(const double& rScaleX, const double& rScaleY)
+ : BitmapScaleConvolutionFilter(rScaleX, rScaleY)
+ {
+ mpKernel = new Lanczos3Kernel();
+ }
};
}
-#endif // INCLUDED_VCL_BITMAPSCALECONVOLUTION_HXX
+#endif // VCL_INC_BITMAPSCALECONVOLUTIONFILTER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/bitmapscalesuper.hxx b/vcl/inc/BitmapScaleSuperFilter.hxx
index c8309c874b77..3b403015a5c9 100644
--- a/vcl/inc/bitmapscalesuper.hxx
+++ b/vcl/inc/BitmapScaleSuperFilter.hxx
@@ -20,19 +20,19 @@
#ifndef INCLUDED_VCL_INC_BITMAPSCALESUPER_HXX
#define INCLUDED_VCL_INC_BITMAPSCALESUPER_HXX
-#include "bitmapfilter.hxx"
+#include <vcl/BitmapFilter.hxx>
class BitmapScaleSuperFilter : public BitmapFilter
{
public:
- BitmapScaleSuperFilter(const double& rScaleX, const double& rScaleY);
- virtual ~BitmapScaleSuperFilter() override;
+ BitmapScaleSuperFilter(const double& rScaleX, const double& rScaleY);
+ virtual ~BitmapScaleSuperFilter() override;
- virtual bool execute(Bitmap& rBitmap) override;
+ virtual BitmapEx execute(BitmapEx const& rBitmap) override;
private:
- double mrScaleX;
- double mrScaleY;
+ double mrScaleX;
+ double mrScaleY;
};
diff --git a/vcl/qa/cppunit/BitmapProcessorTest.cxx b/vcl/qa/cppunit/BitmapProcessorTest.cxx
index 1e46ecd47477..fe49184c3302 100644
--- a/vcl/qa/cppunit/BitmapProcessorTest.cxx
+++ b/vcl/qa/cppunit/BitmapProcessorTest.cxx
@@ -22,10 +22,9 @@
#include <vcl/graphicfilter.hxx>
#include <config_features.h>
-#include <BitmapProcessor.hxx>
+#include <BitmapDisabledImageFilter.hxx>
#include <bitmapwriteaccess.hxx>
-
namespace
{
@@ -46,8 +45,10 @@ void BitmapProcessorTest::testDisabledImage()
pWriteAccess->Erase(Color(0x00, 0x11, 0x22, 0x33));
}
BitmapEx aBitmapEx(aBitmap);
- BitmapEx aDisabledBitmapEx(BitmapProcessor::createDisabledImage(aBitmapEx));
+ BitmapDisabledImageFilter aDisabledImageFilter;
+ BitmapEx aDisabledBitmapEx(aDisabledImageFilter.execute(aBitmapEx));
Bitmap aDisabledBitmap(aDisabledBitmapEx.GetBitmap());
+
{
Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap);
Color aColor(pReadAccess->GetPixel(0, 0).GetColor());
diff --git a/vcl/source/bitmap/BitmapColorizeFilter.cxx b/vcl/source/bitmap/BitmapColorizeFilter.cxx
new file mode 100644
index 000000000000..f9a89ac60dde
--- /dev/null
+++ b/vcl/source/bitmap/BitmapColorizeFilter.cxx
@@ -0,0 +1,94 @@
+/* -*- 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/.
+ *
+ */
+
+#include <tools/color.hxx>
+#include <basegfx/color/bcolortools.hxx>
+
+#include <vcl/bitmapaccess.hxx>
+
+#include <bitmapwriteaccess.hxx>
+#include <BitmapColorizeFilter.hxx>
+
+BitmapEx BitmapColorizeFilter::execute(BitmapEx const& rBitmapEx)
+{
+ Bitmap aBitmap = rBitmapEx.GetBitmap();
+ BitmapScopedWriteAccess pWriteAccess(aBitmap);
+
+ if (!pWriteAccess)
+ return rBitmapEx;
+
+ BitmapColor aBitmapColor;
+ const long nW = pWriteAccess->Width();
+ const long nH = pWriteAccess->Height();
+ std::vector<sal_uInt8> aMapR(256);
+ std::vector<sal_uInt8> aMapG(256);
+ std::vector<sal_uInt8> aMapB(256);
+ long nX;
+ long nY;
+
+ const sal_uInt8 cR = maColor.GetRed();
+ const sal_uInt8 cG = maColor.GetGreen();
+ const sal_uInt8 cB = maColor.GetBlue();
+
+ for (nX = 0; nX < 256; ++nX)
+ {
+ aMapR[nX] = MinMax((nX + cR) / 2, 0, 255);
+ aMapG[nX] = MinMax((nX + cG) / 2, 0, 255);
+ aMapB[nX] = MinMax((nX + cB) / 2, 0, 255);
+ }
+
+ if (pWriteAccess->HasPalette())
+ {
+ for (sal_uInt16 i = 0, nCount = pWriteAccess->GetPaletteEntryCount(); i < nCount; i++)
+ {
+ const BitmapColor& rCol = pWriteAccess->GetPaletteColor(i);
+ aBitmapColor.SetRed(aMapR[rCol.GetRed()]);
+ aBitmapColor.SetGreen(aMapG[rCol.GetGreen()]);
+ aBitmapColor.SetBlue(aMapB[rCol.GetBlue()]);
+ pWriteAccess->SetPaletteColor(i, aBitmapColor);
+ }
+ }
+ else if (pWriteAccess->GetScanlineFormat() == ScanlineFormat::N24BitTcBgr)
+ {
+ for (nY = 0; nY < nH; ++nY)
+ {
+ Scanline pScan = pWriteAccess->GetScanline(nY);
+
+ for (nX = 0; nX < nW; ++nX)
+ {
+ *pScan = aMapB[*pScan];
+ pScan++;
+ *pScan = aMapG[*pScan];
+ pScan++;
+ *pScan = aMapR[*pScan];
+ pScan++;
+ }
+ }
+ }
+ else
+ {
+ for (nY = 0; nY < nH; ++nY)
+ {
+ Scanline pScanline = pWriteAccess->GetScanline(nY);
+ for (nX = 0; nX < nW; ++nX)
+ {
+ aBitmapColor = pWriteAccess->GetPixelFromData(pScanline, nX);
+ aBitmapColor.SetRed(aMapR[aBitmapColor.GetRed()]);
+ aBitmapColor.SetGreen(aMapG[aBitmapColor.GetGreen()]);
+ aBitmapColor.SetBlue(aMapB[aBitmapColor.GetBlue()]);
+ pWriteAccess->SetPixelOnData(pScanline, nX, aBitmapColor);
+ }
+ }
+ }
+
+ return rBitmapEx;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
new file mode 100644
index 000000000000..c341ddea7534
--- /dev/null
+++ b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
@@ -0,0 +1,107 @@
+/* -*- 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/.
+ *
+ */
+
+#include <basegfx/color/bcolortools.hxx>
+
+#include <vcl/bitmapaccess.hxx>
+
+#include <bitmapwriteaccess.hxx>
+#include <BitmapDisabledImageFilter.hxx>
+
+BitmapEx BitmapDisabledImageFilter::execute(BitmapEx const& rBitmapEx)
+{
+ const Size aSize(rBitmapEx.GetSizePixel());
+
+ // keep disable image at same depth as original where possible, otherwise
+ // use 8 bit
+ sal_uInt16 nBitCount = rBitmapEx.GetBitCount();
+ if (nBitCount < 8)
+ nBitCount = 8;
+ const BitmapPalette* pPal = nBitCount == 8 ? &Bitmap::GetGreyPalette(256) : nullptr;
+ Bitmap aGrey(aSize, nBitCount, pPal);
+
+ AlphaMask aGreyAlpha(aSize);
+
+ Bitmap aBitmap(rBitmapEx.GetBitmap());
+ Bitmap::ScopedReadAccess pRead(aBitmap);
+
+ BitmapScopedWriteAccess pGrey(aGrey);
+ AlphaScopedWriteAccess pGreyAlpha(aGreyAlpha);
+
+ BitmapEx aReturnBitmap;
+
+ if (rBitmapEx.IsTransparent())
+ {
+ AlphaMask aBitmapAlpha(rBitmapEx.GetAlpha());
+ AlphaMask::ScopedReadAccess pReadAlpha(aBitmapAlpha);
+
+ if (pRead && pReadAlpha && pGrey && pGreyAlpha)
+ {
+ BitmapColor aGreyAlphaValue(0);
+
+ for (long nY = 0; nY < aSize.Height(); ++nY)
+ {
+ Scanline pScanAlpha = pGreyAlpha->GetScanline(nY);
+ Scanline pScanline = pGrey->GetScanline(nY);
+ Scanline pScanReadAlpha = pReadAlpha->GetScanline(nY);
+
+ for (long nX = 0; nX < aSize.Width(); ++nX)
+ {
+ const sal_uInt8 nLum(pRead->GetLuminance(nY, nX));
+ BitmapColor aGreyValue(nLum, nLum, nLum);
+ pGrey->SetPixelOnData(pScanline, nX, aGreyValue);
+
+ const BitmapColor aBitmapAlphaValue(
+ pReadAlpha->GetPixelFromData(pScanReadAlpha, nX));
+
+ aGreyAlphaValue.SetIndex(
+ sal_uInt8(std::min(aBitmapAlphaValue.GetIndex() + 178ul, 255ul)));
+ pGreyAlpha->SetPixelOnData(pScanAlpha, nX, aGreyAlphaValue);
+ }
+ }
+ }
+
+ pReadAlpha.reset();
+ aReturnBitmap = BitmapEx(aGrey, aGreyAlpha);
+ }
+ else
+ {
+ if (pRead && pGrey && pGreyAlpha)
+ {
+ BitmapColor aGreyAlphaValue(0);
+
+ for (long nY = 0; nY < aSize.Height(); ++nY)
+ {
+ Scanline pScanAlpha = pGreyAlpha->GetScanline(nY);
+ Scanline pScanline = pGrey->GetScanline(nY);
+
+ for (long nX = 0; nX < aSize.Width(); ++nX)
+ {
+ const sal_uInt8 nLum(pRead->GetLuminance(nY, nX));
+ BitmapColor aGreyValue(nLum, nLum, nLum);
+ pGrey->SetPixelOnData(pScanline, nX, aGreyValue);
+
+ aGreyAlphaValue.SetIndex(128);
+ pGreyAlpha->SetPixelOnData(pScanAlpha, nX, aGreyAlphaValue);
+ }
+ }
+ }
+
+ aReturnBitmap = BitmapEx(aGrey);
+ }
+
+ pRead.reset();
+ pGrey.reset();
+ pGreyAlpha.reset();
+
+ return aReturnBitmap;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/BitmapLightenFilter.cxx b/vcl/source/bitmap/BitmapLightenFilter.cxx
new file mode 100644
index 000000000000..1432ce02ae59
--- /dev/null
+++ b/vcl/source/bitmap/BitmapLightenFilter.cxx
@@ -0,0 +1,68 @@
+/* -*- 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/.
+ *
+ */
+
+#include <basegfx/color/bcolortools.hxx>
+
+#include <vcl/bitmapaccess.hxx>
+
+#include <bitmapwriteaccess.hxx>
+#include <BitmapLightenFilter.hxx>
+
+BitmapEx BitmapLightenFilter::execute(BitmapEx const& rBitmapEx)
+{
+ const Size aSize(rBitmapEx.GetSizePixel());
+
+ Bitmap aBitmap(rBitmapEx.GetBitmap());
+ Bitmap aDarkBitmap(aSize, 24);
+
+ Bitmap::ScopedReadAccess pRead(aBitmap);
+ BitmapScopedWriteAccess pWrite(aDarkBitmap);
+
+ if (pRead && pWrite)
+ {
+ for (long nY = 0; nY < aSize.Height(); ++nY)
+ {
+ Scanline pScanline = pWrite->GetScanline(nY);
+ Scanline pScanlineRead = pRead->GetScanline(nY);
+ for (long nX = 0; nX < aSize.Width(); ++nX)
+ {
+ BitmapColor aBmpColor
+ = pRead->HasPalette()
+ ? pRead->GetPaletteColor(pRead->GetIndexFromData(pScanlineRead, nX))
+ : pRead->GetPixelFromData(pScanlineRead, nX);
+ basegfx::BColor aBColor(aBmpColor.Invert().GetColor().getBColor());
+ aBColor = basegfx::utils::rgb2hsl(aBColor);
+
+ double fHue = aBColor.getRed();
+ fHue += 180.0;
+
+ while (fHue > 360.0)
+ {
+ fHue -= 360.0;
+ }
+
+ aBColor.setRed(fHue);
+
+ aBColor = basegfx::utils::hsl2rgb(aBColor);
+ aBmpColor.SetRed((aBColor.getRed() * 255.0) + 0.5);
+ aBmpColor.SetGreen((aBColor.getGreen() * 255.0) + 0.5);
+ aBmpColor.SetBlue((aBColor.getBlue() * 255.0) + 0.5);
+
+ pWrite->SetPixelOnData(pScanline, nX, aBmpColor);
+ }
+ }
+ }
+ pWrite.reset();
+ pRead.reset();
+
+ return BitmapEx(aDarkBitmap, rBitmapEx.GetAlpha());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/BitmapProcessor.cxx b/vcl/source/bitmap/BitmapProcessor.cxx
deleted file mode 100644
index c49f3c489c76..000000000000
--- a/vcl/source/bitmap/BitmapProcessor.cxx
+++ /dev/null
@@ -1,220 +0,0 @@
-/* -*- 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/.
- *
- */
-
-#include <vcl/bitmapaccess.hxx>
-#include <basegfx/color/bcolortools.hxx>
-
-#include <BitmapProcessor.hxx>
-#include <bitmapwriteaccess.hxx>
-
-BitmapEx BitmapProcessor::createLightImage(const BitmapEx& rBitmapEx)
-{
- const Size aSize(rBitmapEx.GetSizePixel());
-
- Bitmap aBitmap(rBitmapEx.GetBitmap());
- Bitmap aDarkBitmap(aSize, 24);
-
- Bitmap::ScopedReadAccess pRead(aBitmap);
- BitmapScopedWriteAccess pWrite(aDarkBitmap);
-
- if (pRead && pWrite)
- {
- for (long nY = 0; nY < aSize.Height(); ++nY)
- {
- Scanline pScanline = pWrite->GetScanline( nY );
- Scanline pScanlineRead = pRead->GetScanline( nY );
- for (long nX = 0; nX < aSize.Width(); ++nX)
- {
- BitmapColor aBmpColor = pRead->HasPalette() ?
- pRead->GetPaletteColor(pRead->GetIndexFromData(pScanlineRead, nX)) :
- pRead->GetPixelFromData(pScanlineRead, nX);
- basegfx::BColor aBColor(aBmpColor.Invert().GetColor().getBColor());
- aBColor = basegfx::utils::rgb2hsl(aBColor);
-
- double fHue = aBColor.getRed();
- fHue += 180.0;
-
- while (fHue > 360.0)
- {
- fHue -= 360.0;
- }
-
- aBColor.setRed(fHue);
-
- aBColor = basegfx::utils::hsl2rgb(aBColor);
- aBmpColor.SetRed((aBColor.getRed() * 255.0) + 0.5);
- aBmpColor.SetGreen((aBColor.getGreen() * 255.0) + 0.5);
- aBmpColor.SetBlue((aBColor.getBlue() * 255.0) + 0.5);
-
- pWrite->SetPixelOnData(pScanline, nX, aBmpColor);
- }
- }
- }
- pWrite.reset();
- pRead.reset();
-
- return BitmapEx(aDarkBitmap, rBitmapEx.GetAlpha());
-}
-
-BitmapEx BitmapProcessor::createDisabledImage(const BitmapEx& rBitmapEx)
-{
- const Size aSize(rBitmapEx.GetSizePixel());
-
- //keep disable image at same depth as original where possible, otherwise
- //use 8 bit
- sal_uInt16 nBitCount = rBitmapEx.GetBitCount();
- if (nBitCount < 8)
- nBitCount = 8;
- const BitmapPalette* pPal = nBitCount == 8 ? &Bitmap::GetGreyPalette(256) : nullptr;
- Bitmap aGrey(aSize, nBitCount, pPal);
-
- AlphaMask aGreyAlpha(aSize);
-
- Bitmap aBitmap(rBitmapEx.GetBitmap());
- Bitmap::ScopedReadAccess pRead(aBitmap);
-
- BitmapScopedWriteAccess pGrey(aGrey);
- AlphaScopedWriteAccess pGreyAlpha(aGreyAlpha);
-
- BitmapEx aReturnBitmap;
-
- if (rBitmapEx.IsTransparent())
- {
- AlphaMask aBitmapAlpha(rBitmapEx.GetAlpha());
- AlphaMask::ScopedReadAccess pReadAlpha(aBitmapAlpha);
-
- if (pRead && pReadAlpha && pGrey && pGreyAlpha)
- {
- BitmapColor aGreyAlphaValue(0);
-
- for (long nY = 0; nY < aSize.Height(); ++nY)
- {
- Scanline pScanAlpha = pGreyAlpha->GetScanline( nY );
- Scanline pScanline = pGrey->GetScanline( nY );
- Scanline pScanReadAlpha = pReadAlpha->GetScanline( nY );
- for (long nX = 0; nX < aSize.Width(); ++nX)
- {
- const sal_uInt8 nLum(pRead->GetLuminance(nY, nX));
- BitmapColor aGreyValue(nLum, nLum, nLum);
- pGrey->SetPixelOnData(pScanline, nX, aGreyValue);
-
- const BitmapColor aBitmapAlphaValue(pReadAlpha->GetPixelFromData(pScanReadAlpha, nX));
-
- aGreyAlphaValue.SetIndex(sal_uInt8(std::min(aBitmapAlphaValue.GetIndex() + 178ul, 255ul)));
- pGreyAlpha->SetPixelOnData(pScanAlpha, nX, aGreyAlphaValue);
- }
- }
- }
- pReadAlpha.reset();
- aReturnBitmap = BitmapEx(aGrey, aGreyAlpha);
- }
- else
- {
- if (pRead && pGrey && pGreyAlpha)
- {
- BitmapColor aGreyAlphaValue(0);
-
- for (long nY = 0; nY < aSize.Height(); ++nY)
- {
- Scanline pScanAlpha = pGreyAlpha->GetScanline( nY );
- Scanline pScanline = pGrey->GetScanline( nY );
- for (long nX = 0; nX < aSize.Width(); ++nX)
- {
- const sal_uInt8 nLum(pRead->GetLuminance(nY, nX));
- BitmapColor aGreyValue(nLum, nLum, nLum);
- pGrey->SetPixelOnData(pScanline, nX, aGreyValue);
-
- aGreyAlphaValue.SetIndex(128);
- pGreyAlpha->SetPixelOnData(pScanAlpha, nX, aGreyAlphaValue);
- }
- }
- }
- aReturnBitmap = BitmapEx(aGrey);
- }
-
- pRead.reset();
- pGrey.reset();
- pGreyAlpha.reset();
-
- return aReturnBitmap;
-}
-
-void BitmapProcessor::colorizeImage(BitmapEx const & rBitmapEx, Color aColor)
-{
- Bitmap aBitmap = rBitmapEx.GetBitmap();
- BitmapScopedWriteAccess pWriteAccess(aBitmap);
-
- if (!pWriteAccess)
- return;
-
- BitmapColor aBitmapColor;
- const long nW = pWriteAccess->Width();
- const long nH = pWriteAccess->Height();
- std::vector<sal_uInt8> aMapR(256);
- std::vector<sal_uInt8> aMapG(256);
- std::vector<sal_uInt8> aMapB(256);
- long nX;
- long nY;
-
- const sal_uInt8 cR = aColor.GetRed();
- const sal_uInt8 cG = aColor.GetGreen();
- const sal_uInt8 cB = aColor.GetBlue();
-
- for (nX = 0; nX < 256; ++nX)
- {
- aMapR[nX] = MinMax((nX + cR) / 2, 0, 255);
- aMapG[nX] = MinMax((nX + cG) / 2, 0, 255);
- aMapB[nX] = MinMax((nX + cB) / 2, 0, 255);
- }
-
- if (pWriteAccess->HasPalette())
- {
- for (sal_uInt16 i = 0, nCount = pWriteAccess->GetPaletteEntryCount(); i < nCount; i++)
- {
- const BitmapColor& rCol = pWriteAccess->GetPaletteColor(i);
- aBitmapColor.SetRed(aMapR[rCol.GetRed()]);
- aBitmapColor.SetGreen(aMapG[rCol.GetGreen()]);
- aBitmapColor.SetBlue(aMapB[rCol.GetBlue()]);
- pWriteAccess->SetPaletteColor(i, aBitmapColor);
- }
- }
- else if (pWriteAccess->GetScanlineFormat() == ScanlineFormat::N24BitTcBgr)
- {
- for (nY = 0; nY < nH; ++nY)
- {
- Scanline pScan = pWriteAccess->GetScanline(nY);
-
- for (nX = 0; nX < nW; ++nX)
- {
- *pScan = aMapB[*pScan]; pScan++;
- *pScan = aMapG[*pScan]; pScan++;
- *pScan = aMapR[*pScan]; pScan++;
- }
- }
- }
- else
- {
- for (nY = 0; nY < nH; ++nY)
- {
- Scanline pScanline = pWriteAccess->GetScanline( nY );
- for (nX = 0; nX < nW; ++nX)
- {
- aBitmapColor = pWriteAccess->GetPixelFromData(pScanline, nX);
- aBitmapColor.SetRed(aMapR[aBitmapColor.GetRed()]);
- aBitmapColor.SetGreen(aMapG[aBitmapColor.GetGreen()]);
- aBitmapColor.SetBlue(aMapB[aBitmapColor.GetBlue()]);
- pWriteAccess->SetPixelOnData(pScanline, nX, aBitmapColor);
- }
- }
- }
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/BitmapScaleConvolution.cxx b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
index 14e391c1ee77..4997812a2cb5 100644..100755
--- a/vcl/source/bitmap/BitmapScaleConvolution.cxx
+++ b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
@@ -17,12 +17,12 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <BitmapScaleConvolution.hxx>
-#include <ResampleKernel.hxx>
-#include <bitmapwriteaccess.hxx>
+#include <osl/diagnose.h>
#include <vcl/bitmapaccess.hxx>
-#include <osl/diagnose.h>
+
+#include <bitmapwriteaccess.hxx>
+#include <BitmapScaleConvolutionFilter.hxx>
#include <algorithm>
#include <memory>
@@ -372,21 +372,17 @@ bool ImplScaleConvolution(Bitmap& rBitmap, const double& rScaleX, const double&
} // end anonymous namespace
-bool BitmapScaleConvolutionFilter::execute(Bitmap& rBitmap)
+BitmapEx BitmapScaleConvolutionFilter::execute(BitmapEx const& rBitmapEx)
{
+ bool bRetval = false;
+ Bitmap aBitmap(rBitmapEx.GetBitmap());
- switch(meKernelType)
- {
- case ConvolutionKernelType::BiLinear:
- return ImplScaleConvolution(rBitmap, mrScaleX, mrScaleY, BilinearKernel());
- case ConvolutionKernelType::BiCubic:
- return ImplScaleConvolution(rBitmap, mrScaleX, mrScaleY, BicubicKernel());
- case ConvolutionKernelType::Lanczos3:
- return ImplScaleConvolution(rBitmap, mrScaleX, mrScaleY, Lanczos3Kernel());
- default:
- break;
- }
- return false;
+ bRetval = ImplScaleConvolution(aBitmap, mrScaleX, mrScaleY, *mpKernel);
+
+ if (bRetval)
+ return BitmapEx(aBitmap);
+
+ return BitmapEx();
}
}
diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
index c653a81bf929..2bea98bcbb29 100644..100755
--- a/vcl/source/bitmap/bitmapscalesuper.cxx
+++ b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
@@ -17,13 +17,15 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <comphelper/threadpool.hxx>
+
#include <vcl/bitmapaccess.hxx>
-#include <bitmapscalesuper.hxx>
+
#include <bitmapwriteaccess.hxx>
+#include <BitmapScaleSuperFilter.hxx>
#include <algorithm>
#include <memory>
-#include <comphelper/threadpool.hxx>
namespace {
@@ -927,8 +929,10 @@ BitmapScaleSuperFilter::BitmapScaleSuperFilter(const double& rScaleX, const doub
BitmapScaleSuperFilter::~BitmapScaleSuperFilter()
{}
-bool BitmapScaleSuperFilter::execute(Bitmap& rBitmap)
+BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap)
{
+ Bitmap aBitmap(rBitmap.GetBitmap());
+
bool bRet = false;
const Size aSizePix(rBitmap.GetSizePixel());
@@ -945,122 +949,132 @@ bool BitmapScaleSuperFilter::execute(Bitmap& rBitmap)
const double fScaleThresh = 0.6;
if (nDstW <= 1 || nDstH <= 1)
- return false;
+ return BitmapEx();
+ {
+ Bitmap::ScopedReadAccess pReadAccess(aBitmap);
- Bitmap::ScopedReadAccess pReadAccess(rBitmap);
+ Bitmap aOutBmp(Size(nDstW, nDstH), 24);
- Bitmap aOutBmp(Size(nDstW, nDstH), 24);
- BitmapScopedWriteAccess pWriteAccess(aOutBmp);
+ BitmapScopedWriteAccess pWriteAccess(aOutBmp);
- const long nStartY = 0;
- const long nEndY = nDstH - 1;
+ const long nStartY = 0;
+ const long nEndY = nDstH - 1;
- if (pReadAccess && pWriteAccess)
- {
- ScaleRangeFn pScaleRangeFn;
- ScaleContext aContext( pReadAccess.get(),
- pWriteAccess.get(),
- pReadAccess->Width(),
- pWriteAccess->Width(),
- pReadAccess->Height(),
- pWriteAccess->Height(),
- bVMirr, bHMirr );
-
- bool bScaleUp = fScaleX >= fScaleThresh && fScaleY >= fScaleThresh;
- if( pReadAccess->HasPalette() )
+ if (pReadAccess && pWriteAccess)
{
- switch( pReadAccess->GetScanlineFormat() )
+ ScaleRangeFn pScaleRangeFn;
+ ScaleContext aContext( pReadAccess.get(),
+ pWriteAccess.get(),
+ pReadAccess->Width(),
+ pWriteAccess->Width(),
+ pReadAccess->Height(),
+ pWriteAccess->Height(),
+ bVMirr, bHMirr );
+
+ bool bScaleUp = fScaleX >= fScaleThresh && fScaleY >= fScaleThresh;
+ if( pReadAccess->HasPalette() )
{
- case ScanlineFormat::N8BitPal:
- pScaleRangeFn = bScaleUp ? scalePallete8bit : scalePallete8bit2;
- break;
- default:
- pScaleRangeFn = bScaleUp ? scalePalleteGeneral
- : scalePalleteGeneral2;
- break;
+ switch( pReadAccess->GetScanlineFormat() )
+ {
+ case ScanlineFormat::N8BitPal:
+ pScaleRangeFn = bScaleUp ? scalePallete8bit : scalePallete8bit2;
+ break;
+ default:
+ pScaleRangeFn = bScaleUp ? scalePalleteGeneral
+ : scalePalleteGeneral2;
+ break;
+ }
}
- }
- else
- {
- switch( pReadAccess->GetScanlineFormat() )
+ else
{
- case ScanlineFormat::N24BitTcBgr:
- pScaleRangeFn = bScaleUp ? scale24bitBGR : scale24bitBGR2;
- break;
- case ScanlineFormat::N24BitTcRgb:
- pScaleRangeFn = bScaleUp ? scale24bitRGB : scale24bitRGB2;
- break;
- default:
- pScaleRangeFn = bScaleUp ? scaleNonPalleteGeneral
- : scaleNonPalleteGeneral2;
- break;
+ switch( pReadAccess->GetScanlineFormat() )
+ {
+ case ScanlineFormat::N24BitTcBgr:
+ pScaleRangeFn = bScaleUp ? scale24bitBGR : scale24bitBGR2;
+ break;
+ case ScanlineFormat::N24BitTcRgb:
+ pScaleRangeFn = bScaleUp ? scale24bitRGB : scale24bitRGB2;
+ break;
+ default:
+ pScaleRangeFn = bScaleUp ? scaleNonPalleteGeneral
+ : scaleNonPalleteGeneral2;
+ break;
+ }
}
- }
- // We want to thread - only if there is a lot of work to do:
- // We work hard when there is a large destination image, or
- // A large source image.
- bool bHorizontalWork = pReadAccess->Width() > 512 || pWriteAccess->Width() > 512;
- bool bUseThreads = true;
+ // We want to thread - only if there is a lot of work to do:
+ // We work hard when there is a large destination image, or
+ // A large source image.
+ bool bHorizontalWork = pReadAccess->Width() > 512 || pWriteAccess->Width() > 512;
+ bool bUseThreads = true;
- static bool bDisableThreadedScaling = getenv ("VCL_NO_THREAD_SCALE");
- if ( bDisableThreadedScaling || !bHorizontalWork ||
- nEndY - nStartY < SCALE_THREAD_STRIP )
- {
- SAL_INFO("vcl.gdi", "Scale in main thread");
- bUseThreads = false;
- }
+ static bool bDisableThreadedScaling = getenv ("VCL_NO_THREAD_SCALE");
+ if ( bDisableThreadedScaling || !bHorizontalWork ||
+ nEndY - nStartY < SCALE_THREAD_STRIP )
+ {
+ SAL_INFO("vcl.gdi", "Scale in main thread");
+ bUseThreads = false;
+ }
- if (bUseThreads)
- {
- try
+ if (bUseThreads)
{
- // partition and queue work
- comphelper::ThreadPool &rShared = comphelper::ThreadPool::getSharedOptimalPool();
- std::shared_ptr<comphelper::ThreadTaskTag> pTag = comphelper::ThreadPool::createThreadTaskTag();
- sal_uInt32 nThreads = rShared.getWorkerCount();
- assert( nThreads > 0 );
- sal_uInt32 nStrips = ((nEndY - nStartY) + SCALE_THREAD_STRIP - 1) / SCALE_THREAD_STRIP;
- sal_uInt32 nStripsPerThread = nStrips / nThreads;
- SAL_INFO("vcl.gdi", "Scale in " << nStrips << " strips " << nStripsPerThread << " per thread we have " << nThreads << " CPU threads ");
- long nStripY = nStartY;
- for ( sal_uInt32 t = 0; t < nThreads - 1; t++ )
+ try
{
- ScaleTask *pTask = new ScaleTask( pTag, pScaleRangeFn );
- for ( sal_uInt32 j = 0; j < nStripsPerThread; j++ )
+ // partition and queue work
+ comphelper::ThreadPool &rShared = comphelper::ThreadPool::getSharedOptimalPool();
+ std::shared_ptr<comphelper::ThreadTaskTag> pTag = comphelper::ThreadPool::createThreadTaskTag();
+ sal_uInt32 nThreads = rShared.getWorkerCount();
+ assert( nThreads > 0 );
+ sal_uInt32 nStrips = ((nEndY - nStartY) + SCALE_THREAD_STRIP - 1) / SCALE_THREAD_STRIP;
+ sal_uInt32 nStripsPerThread = nStrips / nThreads;
+ SAL_INFO("vcl.gdi", "Scale in " << nStrips << " strips " << nStripsPerThread << " per thread we have " << nThreads << " CPU threads ");
+ long nStripY = nStartY;
+ for ( sal_uInt32 t = 0; t < nThreads - 1; t++ )
{
- ScaleRangeContext aRC( &aContext, nStripY );
- pTask->push( aRC );
- nStripY += SCALE_THREAD_STRIP;
+ ScaleTask *pTask = new ScaleTask( pTag, pScaleRangeFn );
+ for ( sal_uInt32 j = 0; j < nStripsPerThread; j++ )
+ {
+ ScaleRangeContext aRC( &aContext, nStripY );
+ pTask->push( aRC );
+ nStripY += SCALE_THREAD_STRIP;
+ }
+ rShared.pushTask( pTask );
}
- rShared.pushTask( pTask );
- }
- // finish any remaining bits here
- pScaleRangeFn( aContext, nStripY, nEndY );
+ // finish any remaining bits here
+ pScaleRangeFn( aContext, nStripY, nEndY );
- rShared.waitUntilDone(pTag);
- SAL_INFO("vcl.gdi", "All threaded scaling tasks complete");
+ rShared.waitUntilDone(pTag);
+ SAL_INFO("vcl.gdi", "All threaded scaling tasks complete");
+ }
+ catch (...)
+ {
+ SAL_WARN("vcl.gdi", "threaded bitmap scaling failed");
+ bUseThreads = false;
+ }
}
- catch (...)
+
+ if (!bUseThreads)
+ pScaleRangeFn( aContext, nStartY, nEndY );
+
+ bRet = true;
+
+ if (bRet)
{
- SAL_WARN("vcl.gdi", "threaded bitmap scaling failed");
- bUseThreads = false;
+ aBitmap.AdaptBitCount(aOutBmp);
+ aBitmap = aOutBmp;
}
}
-
- if (!bUseThreads)
- pScaleRangeFn( aContext, nStartY, nEndY );
-
- bRet = true;
}
- if( bRet )
+ if (bRet)
{
- rBitmap.AdaptBitCount(aOutBmp);
- rBitmap = aOutBmp;
+ tools::Rectangle aRect(Point(0, 0), Point(nDstW, nDstH));
+ aBitmap.Crop(aRect);
+ return BitmapEx(aBitmap);
}
- return bRet;
+ return BitmapEx();
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/bitmapfilter.cxx b/vcl/source/bitmap/bitmapfilter.cxx
index 34ff09f56799..4f4ae5ae0961 100644
--- a/vcl/source/bitmap/bitmapfilter.cxx
+++ b/vcl/source/bitmap/bitmapfilter.cxx
@@ -8,7 +8,7 @@
*
*/
-#include <bitmapfilter.hxx>
+#include <vcl/BitmapFilter.hxx>
BitmapFilter::BitmapFilter()
{}
@@ -16,4 +16,18 @@ BitmapFilter::BitmapFilter()
BitmapFilter::~BitmapFilter()
{}
+bool BitmapFilter::Filter(BitmapEx &rBmpEx, BitmapFilter &&rFilter)
+{
+ BitmapEx aTmpBmpEx(rFilter.execute(rBmpEx));
+
+ if (aTmpBmpEx.IsEmpty())
+ {
+ SAL_WARN("vcl.gdi", "Bitmap filter failed");
+ return false;
+ }
+
+ rBmpEx = aTmpBmpEx;
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 24deaffc640b..b933e41ba2f1 100644..100755
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -27,16 +27,17 @@
#if HAVE_FEATURE_OPENGL
#include <vcl/opengl/OpenGLHelper.hxx>
#endif
-#include <memory>
#include <impbmp.hxx>
#include <impoctree.hxx>
+#include <BitmapScaleSuperFilter.hxx>
+#include <BitmapScaleConvolutionFilter.hxx>
+#include <bitmapwriteaccess.hxx>
+#include <octree.hxx>
+
#include "impvect.hxx"
-#include <bitmapscalesuper.hxx>
-#include <octree.hxx>
-#include <BitmapScaleConvolution.hxx>
-#include <bitmapwriteaccess.hxx>
+#include <memory>
#define RGB15( _def_cR, _def_cG, _def_cB ) ((static_cast<sal_uLong>(_def_cR)<<10)|(static_cast<sal_uLong>(_def_cG)<<5)|static_cast<sal_uLong>(_def_cB))
#define GAMMA( _def_cVal, _def_InvGamma ) (static_cast<sal_uInt8>(MinMax(FRound(pow( _def_cVal/255.0,_def_InvGamma)*255.0),0,255)))
@@ -738,71 +739,59 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag n
}
}
- //fdo#33455
+ // fdo#33455
//
- //If we start with a 1 bit image, then after scaling it in any mode except
- //BmpScaleFlag::Fast we have a 24bit image which is perfectly correct, but we
- //are going to down-shift it to mono again and Bitmap::MakeMonochrome just
- //has "Bitmap aNewBmp( GetSizePixel(), 1 );" to create a 1 bit bitmap which
- //will default to black/white and the colors mapped to which ever is closer
- //to black/white
+ // If we start with a 1 bit image, then after scaling it in any mode except
+ // BmpScaleFlag::Fast we have a 24bit image which is perfectly correct, but we
+ // are going to down-shift it to mono again and Bitmap::MakeMonochrome just
+ // has "Bitmap aNewBmp( GetSizePixel(), 1 );" to create a 1 bit bitmap which
+ // will default to black/white and the colors mapped to which ever is closer
+ // to black/white
//
- //So the easiest thing to do to retain the colors of 1 bit bitmaps is to
- //just use the fast scale rather than attempting to count unique colors in
- //the other converters and pass all the info down through
- //Bitmap::MakeMonochrome
+ // So the easiest thing to do to retain the colors of 1 bit bitmaps is to
+ // just use the fast scale rather than attempting to count unique colors in
+ // the other converters and pass all the info down through
+ // Bitmap::MakeMonochrome
if (nStartCount == 1)
nScaleFlag = BmpScaleFlag::Fast;
+ BitmapEx aBmpEx(*this);
bool bRetval(false);
switch(nScaleFlag)
{
- case BmpScaleFlag::Fast :
- {
+ case BmpScaleFlag::Fast:
bRetval = ImplScaleFast( rScaleX, rScaleY );
break;
- }
- case BmpScaleFlag::Interpolate :
- {
- bRetval = ImplScaleInterpolate( rScaleX, rScaleY );
+
+ case BmpScaleFlag::Interpolate:
+ bRetval = ImplScaleInterpolate(rScaleX, rScaleY);
break;
- }
+
case BmpScaleFlag::Default:
- {
if (GetSizePixel().Width() < 2 || GetSizePixel().Height() < 2)
- {
- // fallback to ImplScaleFast
- bRetval = ImplScaleFast( rScaleX, rScaleY );
- }
+ bRetval = ImplScaleFast(rScaleX, rScaleY);
else
- {
- BitmapScaleSuperFilter aScaleSuperFilter(rScaleX, rScaleY);
- bRetval = aScaleSuperFilter.execute(*this);
- }
+ bRetval = BitmapFilter::Filter(aBmpEx, BitmapScaleSuperFilter(rScaleX, rScaleY));
break;
- }
- case BmpScaleFlag::Lanczos :
+
+ case BmpScaleFlag::Lanczos:
case BmpScaleFlag::BestQuality:
- {
- vcl::BitmapScaleConvolutionFilter aScaleConvolutionFilter(rScaleX, rScaleY, vcl::ConvolutionKernelType::Lanczos3);
- bRetval = aScaleConvolutionFilter.execute(*this);
+ bRetval = BitmapFilter::Filter(aBmpEx, vcl::BitmapScaleLanczos3Filter(rScaleX, rScaleY));
break;
- }
- case BmpScaleFlag::BiCubic :
- {
- vcl::BitmapScaleConvolutionFilter aScaleConvolutionFilter(rScaleX, rScaleY, vcl::ConvolutionKernelType::BiCubic);
- bRetval = aScaleConvolutionFilter.execute(*this);
+
+ case BmpScaleFlag::BiCubic:
+ bRetval = BitmapFilter::Filter(aBmpEx, vcl::BitmapScaleBicubicFilter(rScaleX, rScaleY));
break;
- }
- case BmpScaleFlag::BiLinear :
- {
- vcl::BitmapScaleConvolutionFilter aScaleConvolutionFilter(rScaleX, rScaleY, vcl::ConvolutionKernelType::BiLinear);
- bRetval = aScaleConvolutionFilter.execute(*this);
+
+ case BmpScaleFlag::BiLinear:
+ bRetval = BitmapFilter::Filter(aBmpEx, vcl::BitmapScaleBilinearFilter(rScaleX, rScaleY));
break;
- }
}
+ if (bRetval && nScaleFlag != BmpScaleFlag::Fast && nScaleFlag != BmpScaleFlag::Interpolate)
+ *this = aBmpEx.GetBitmapRef();
+
OSL_ENSURE(!bRetval || nStartCount == GetBitCount(), "Bitmap::Scale has changed the ColorDepth, this should *not* happen (!)");
return bRetval;
}
@@ -1132,10 +1121,8 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY
}
}
- if( !bRet )
- {
- bRet = ImplScaleFast( rScaleX, rScaleY );
- }
+ if (!bRet)
+ bRet = ImplScaleFast(rScaleX, rScaleY);
return bRet;
}
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index ed49233ddaf8..d107c55631f0 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -19,11 +19,12 @@
#include <rtl/crc.h>
#include <rtl/strbuf.hxx>
-
#include <o3tl/any.hxx>
#include <tools/debug.hxx>
#include <unotools/resmgr.hxx>
#include <tools/stream.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
#include <vcl/ImageTree.hxx>
#include <vcl/salbtype.hxx>
#include <vcl/outdev.hxx>
@@ -35,16 +36,16 @@
#include <vcl/virdev.hxx>
#include <vcl/settings.hxx>
-#include <image.h>
-#include <basegfx/matrix/b2dhommatrixtools.hxx>
-
// BitmapEx::Create
#include <salbmp.hxx>
#include <salinst.hxx>
#include <svdata.hxx>
+#include <bitmapwriteaccess.hxx>
+#include <image.h>
+
#include <com/sun/star/beans/XFastPropertySet.hpp>
+
#include <memory>
-#include <bitmapwriteaccess.hxx>
using namespace ::com::sun::star;
@@ -118,6 +119,7 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ) :
meTransparent ( !rMask ? TransparentType::NONE : TransparentType::Bitmap ),
mbAlpha ( false )
{
+ SAL_INFO("vcl.gdi", "Bitmap size: " << maBitmapSize);
// Ensure a mask is exactly one bit deep
if( !!maMask && maMask.GetBitCount() != 1 )
{
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index e9e105c10bf0..7be04691603d 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -31,7 +31,8 @@
#include <sal/types.h>
#include <image.h>
-#include <BitmapProcessor.hxx>
+#include <BitmapDisabledImageFilter.hxx>
+#include <BitmapColorizeFilter.hxx>
#if OSL_DEBUG_LEVEL > 0
#include <rtl/strbuf.hxx>
@@ -137,8 +138,11 @@ void Image::Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle
BitmapChecksum aChecksum = mpImplData->maBitmapEx.GetChecksum();
if (mpImplData->maBitmapChecksum != aChecksum)
{
+ BitmapEx aDisabledBmpEx(mpImplData->maBitmapEx);
+ BitmapFilter::Filter(aDisabledBmpEx, BitmapDisabledImageFilter());
+
mpImplData->maBitmapChecksum = aChecksum;
- mpImplData->maDisabledBitmapEx = BitmapProcessor::createDisabledImage(mpImplData->maBitmapEx);
+ mpImplData->maDisabledBitmapEx = aDisabledBmpEx;
}
pOutDev->DrawBitmapEx(rPos, aOutSize, aSrcPos, aBitmapSizePixel, mpImplData->maDisabledBitmapEx);
}
@@ -158,7 +162,7 @@ void Image::Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle
else
aColor = rSettings.GetDeactiveColor();
- BitmapProcessor::colorizeImage(aTempBitmapEx, aColor);
+ BitmapFilter::Filter(aTempBitmapEx, BitmapColorizeFilter(aColor));
}
if (nStyle & DrawImageFlags::SemiTransparent)
diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx
index b6803009a3b4..d27eaec8d018 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -50,7 +50,7 @@
#include <vcl/IconThemeScanner.hxx>
#include <vcl/pngwrite.hxx>
-#include <BitmapProcessor.hxx>
+#include <BitmapLightenFilter.hxx>
bool ImageRequestParameters::convertToDarkTheme()
{
@@ -160,8 +160,10 @@ void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString con
{
rParameters.mbWriteImageToCache = true; // We always want to cache a SVG image
vcl::bitmap::loadFromSvg(*xStream.get(), rPath, rParameters.mrBitmap, aScalePercentage / 100.0);
+
if (bConvertToDarkTheme)
- rParameters.mrBitmap = BitmapProcessor::createLightImage(rParameters.mrBitmap);
+ BitmapFilter::Filter(rParameters.mrBitmap, BitmapLightenFilter());
+
return;
}
else
@@ -172,7 +174,7 @@ void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString con
if (bConvertToDarkTheme)
{
rParameters.mbWriteImageToCache = true; // Cache the dark variant
- rParameters.mrBitmap = BitmapProcessor::createLightImage(rParameters.mrBitmap);
+ BitmapFilter::Filter(rParameters.mrBitmap, BitmapLightenFilter());
}
if (aScalePercentage > 100)