include/vcl/BitmapMonochromeMatrixFilter.hxx | 28 ---- include/vcl/bitmap.hxx | 4 vcl/Library_vcl.mk | 1 vcl/source/bitmap/BitmapMonochromeMatrixFilter.cxx | 142 --------------------- vcl/source/gdi/bitmap3.cxx | 87 ------------ 5 files changed, 262 deletions(-)
New commits: commit e3cc7b94b13d6cc4e044cfd688e0fcc9dca63987 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Apr 24 11:30:57 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Apr 24 13:37:12 2020 +0200 loplugin:unusedenumconstants BmpConversion Change-Id: Ib1c36a35ffa6af535b5265f753e9b7a6bfb590a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92841 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/vcl/BitmapMonochromeMatrixFilter.hxx b/include/vcl/BitmapMonochromeMatrixFilter.hxx deleted file mode 100644 index 58d1d917f65d..000000000000 --- a/include/vcl/BitmapMonochromeMatrixFilter.hxx +++ /dev/null @@ -1,28 +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/. - * - */ - -#ifndef INCLUDED_INCLUDE_VCL_BITMAPMONOCHROMEMATRIXFILTER_HXX -#define INCLUDED_INCLUDE_VCL_BITMAPMONOCHROMEMATRIXFILTER_HXX - -#include <vcl/BitmapFilter.hxx> - -class VCL_DLLPUBLIC BitmapMonochromeMatrixFilter final : public BitmapFilter -{ -public: - /** Convert to monochrome (1-bit) bitmap using dithering - */ - BitmapMonochromeMatrixFilter() {} - - virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index 1df24105e8bd..742e7a3a56f8 100644 --- a/include/vcl/bitmap.hxx +++ b/include/vcl/bitmap.hxx @@ -66,7 +66,6 @@ enum class BmpConversion { NNONE, N1BitThreshold, - N1BitMatrix, // aka Dithered, used in export to bitmap N4BitGreys, N4BitColors, N8BitGreys, @@ -74,7 +73,6 @@ enum class BmpConversion N24Bit, N32Bit, N8BitTrans, - Ghosted, N8BitNoConversion // make 8bit without color conversion (e.g. take the red channel) }; @@ -537,8 +535,6 @@ private: SAL_DLLPRIVATE bool ImplConvertUp(sal_uInt16 nBitCount, Color const* pExtColor = nullptr); SAL_DLLPRIVATE bool ImplConvertDown(sal_uInt16 nBitCount, Color const* pExtColor = nullptr); - SAL_DLLPRIVATE bool ImplConvertGhosted(); - private: std::shared_ptr<SalBitmap> mxSalBmp; MapMode maPrefMapMode; diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index fe3afd7de9a4..cb59e378fb89 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -332,7 +332,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/bitmap/bitmapfilter \ vcl/source/bitmap/BitmapAlphaClampFilter \ vcl/source/bitmap/BitmapMonochromeFilter \ - vcl/source/bitmap/BitmapMonochromeMatrixFilter \ vcl/source/bitmap/BitmapSmoothenFilter \ vcl/source/bitmap/BitmapLightenFilter \ vcl/source/bitmap/BitmapDisabledImageFilter \ diff --git a/vcl/source/bitmap/BitmapMonochromeMatrixFilter.cxx b/vcl/source/bitmap/BitmapMonochromeMatrixFilter.cxx deleted file mode 100644 index 12e72ad1c710..000000000000 --- a/vcl/source/bitmap/BitmapMonochromeMatrixFilter.cxx +++ /dev/null @@ -1,142 +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/bitmap.hxx> -#include <vcl/bitmapex.hxx> -#include <vcl/BitmapMonochromeMatrixFilter.hxx> -#include <vcl/bitmapaccess.hxx> - -#include <bitmapwriteaccess.hxx> - -static void ImplCreateDitherMatrix(sal_uInt8 (*pDitherMatrix)[16][16]) -{ - const double fVal = 3.125; - const double fVal16 = fVal / 16.; - const double fValScale = 254.; - sal_uInt16 pMtx[16][16]; - sal_uInt16 nMax = 0; - static const sal_uInt8 pMagic[4][4] = { { - 0, - 14, - 3, - 13, - }, - { - 11, - 5, - 8, - 6, - }, - { - 12, - 2, - 15, - 1, - }, - { 7, 9, 4, 10 } }; - - // Build MagicSquare - for (long i = 0; i < 4; i++) - for (long j = 0; j < 4; j++) - for (long k = 0; k < 4; k++) - for (long l = 0; l < 4; l++) - { - pMtx[(k << 2) + i][(l << 2) + j] = static_cast<sal_uInt16>( - 0.5 + pMagic[i][j] * fVal + pMagic[k][l] * fVal16); - nMax = std::max(pMtx[(k << 2) + i][(l << 2) + j], nMax); - } - - // Scale to interval [0;254] - double tmp = fValScale / nMax; - for (long i = 0; i < 16; i++) - for (long j = 0; j < 16; j++) - (*pDitherMatrix)[i][j] = static_cast<sal_uInt8>(tmp * pMtx[i][j]); -} - -BitmapEx BitmapMonochromeMatrixFilter::execute(BitmapEx const& aBitmapEx) const -{ - Bitmap aBitmap = aBitmapEx.GetBitmap(); - Bitmap::ScopedReadAccess pReadAcc(aBitmap); - bool bRet = false; - - if (pReadAcc) - { - Bitmap aNewBmp(aBitmap.GetSizePixel(), 1); - BitmapScopedWriteAccess pWriteAcc(aNewBmp); - - if (pWriteAcc) - { - const BitmapColor aBlack(pWriteAcc->GetBestMatchingColor(COL_BLACK)); - const BitmapColor aWhite(pWriteAcc->GetBestMatchingColor(COL_WHITE)); - const long nWidth = pWriteAcc->Width(); - const long nHeight = pWriteAcc->Height(); - sal_uInt8 pDitherMatrix[16][16]; - - ImplCreateDitherMatrix(&pDitherMatrix); - - if (pReadAcc->HasPalette()) - { - for (long nY = 0; nY < nHeight; nY++) - { - for (long nX = 0, nModY = nY % 16; nX < nWidth; nX++) - { - const sal_uInt8 cIndex = pReadAcc->GetPixelIndex(nY, nX); - if (pReadAcc->GetPaletteColor(cIndex).GetLuminance() - > pDitherMatrix[nModY][nX % 16]) - { - pWriteAcc->SetPixel(nY, nX, aWhite); - } - else - pWriteAcc->SetPixel(nY, nX, aBlack); - } - } - } - else - { - for (long nY = 0; nY < nHeight; nY++) - { - for (long nX = 0, nModY = nY % 16; nX < nWidth; nX++) - { - if (pReadAcc->GetPixel(nY, nX).GetLuminance() - > pDitherMatrix[nModY][nX % 16]) - { - pWriteAcc->SetPixel(nY, nX, aWhite); - } - else - pWriteAcc->SetPixel(nY, nX, aBlack); - } - } - } - - pWriteAcc.reset(); - bRet = true; - } - - pReadAcc.reset(); - - if (bRet) - { - const MapMode aMap(aBitmap.GetPrefMapMode()); - const Size aSize(aBitmap.GetPrefSize()); - - aBitmap = aNewBmp; - - aBitmap.SetPrefMapMode(aMap); - aBitmap.SetPrefSize(aSize); - } - } - - if (bRet) - return BitmapEx(aBitmap); - - return BitmapEx(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index c400008e60b4..b2976039f86d 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -30,7 +30,6 @@ #include <vcl/opengl/OpenGLHelper.hxx> #endif #include <vcl/BitmapMonochromeFilter.hxx> -#include <vcl/BitmapMonochromeMatrixFilter.hxx> #include <BitmapScaleSuperFilter.hxx> #include <BitmapScaleConvolutionFilter.hxx> @@ -266,14 +265,6 @@ bool Bitmap::Convert( BmpConversion eConversion ) } break; - case BmpConversion::N1BitMatrix: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapMonochromeMatrixFilter()); - *this = aBmpEx.GetBitmap(); - } - break; - case BmpConversion::N4BitGreys: bRet = ImplMakeGreyscales( 16 ); break; @@ -334,10 +325,6 @@ bool Bitmap::Convert( BmpConversion eConversion ) } break; - case BmpConversion::Ghosted: - bRet = ImplConvertGhosted(); - break; - default: OSL_FAIL( "Bitmap::Convert(): Unsupported conversion" ); break; @@ -680,80 +667,6 @@ bool Bitmap::ImplConvertDown(sal_uInt16 nBitCount, Color const * pExtColor) return bRet; } -bool Bitmap::ImplConvertGhosted() -{ - Bitmap aNewBmp; - ScopedReadAccess pR(*this); - bool bRet = false; - - if( pR ) - { - if( pR->HasPalette() ) - { - BitmapPalette aNewPal( pR->GetPaletteEntryCount() ); - - for( long i = 0, nCount = aNewPal.GetEntryCount(); i < nCount; i++ ) - { - const BitmapColor& rOld = pR->GetPaletteColor( static_cast<sal_uInt16>(i) ); - aNewPal[ static_cast<sal_uInt16>(i) ] = BitmapColor( ( rOld.GetRed() >> 1 ) | 0x80, - ( rOld.GetGreen() >> 1 ) | 0x80, - ( rOld.GetBlue() >> 1 ) | 0x80 ); - } - - aNewBmp = Bitmap( GetSizePixel(), GetBitCount(), &aNewPal ); - BitmapScopedWriteAccess pW(aNewBmp); - - if( pW ) - { - pW->CopyBuffer( *pR ); - bRet = true; - } - } - else - { - aNewBmp = Bitmap( GetSizePixel(), 24 ); - - BitmapScopedWriteAccess pW(aNewBmp); - - if( pW ) - { - const long nWidth = pR->Width(), nHeight = pR->Height(); - - for( long nY = 0; nY < nHeight; nY++ ) - { - Scanline pScanline = pW->GetScanline(nY); - Scanline pScanlineRead = pR->GetScanline(nY); - for( long nX = 0; nX < nWidth; nX++ ) - { - const BitmapColor aOld( pR->GetPixelFromData( pScanlineRead, nX ) ); - pW->SetPixelOnData( pScanline, nX, BitmapColor( ( aOld.GetRed() >> 1 ) | 0x80, - ( aOld.GetGreen() >> 1 ) | 0x80, - ( aOld.GetBlue() >> 1 ) | 0x80 ) ); - - } - } - - bRet = true; - } - } - - pR.reset(); - } - - if( bRet ) - { - const MapMode aMap( maPrefMapMode ); - const Size aSize( maPrefSize ); - - *this = aNewBmp; - - maPrefMapMode = aMap; - maPrefSize = aSize; - } - - return bRet; -} - bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) { if(basegfx::fTools::equalZero(rScaleX) || basegfx::fTools::equalZero(rScaleY)) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits