diff options
41 files changed, 157 insertions, 379 deletions
diff --git a/avmedia/source/gstreamer/gstframegrabber.cxx b/avmedia/source/gstreamer/gstframegrabber.cxx index ece799d87530..6f41511dc128 100644 --- a/avmedia/source/gstreamer/gstframegrabber.cxx +++ b/avmedia/source/gstreamer/gstframegrabber.cxx @@ -146,7 +146,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe pData = aMapInfo.data; int nStride = GST_ROUND_UP_4( nWidth * 3 ); - BitmapEx aBmp = vcl::bitmap::CreateFromData(pData, nWidth, nHeight, nStride, vcl::PixelFormat::N24_BPP); + BitmapEx aBmp = vcl::bitmap::CreateFromData(pData, nWidth, nHeight, nStride, /*nBitsPerPixel*/24); gst_buffer_unmap( pBuf, &aMapInfo ); xRet = Graphic( aBmp ).GetXGraphic(); diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index 130d19af95f7..1fef9c48cce7 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -210,7 +210,7 @@ namespace Bitmap aMask( rBitmap.CreateMask( aWhite )); Bitmap aSolid( rBitmap.GetSizePixel(), - vcl::PixelFormat::N1_BPP, + vcl::PixelFormat::N8_BPP, &aBiLevelPalette ); aSolid.Erase( rMaskColor ); diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 5d897c40f1da..181366e6a19e 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3357,7 +3357,7 @@ void DesktopLOKTest::testRenderSearchResult_WriterNode() CPPUNIT_ASSERT_EQUAL(size_t(1440648), nByteSize); const sal_uInt8* pD = reinterpret_cast<const sal_uInt8*>(pBuffer); - BitmapEx aBitmap = vcl::bitmap::CreateFromData(pD, nWidth, nHeight, nWidth * 4, vcl::PixelFormat::N32_BPP, true, true); + BitmapEx aBitmap = vcl::bitmap::CreateFromData(pD, nWidth, nHeight, nWidth * 4, /*nBitsPerPixel*/32, true, true); if (bDumpBitmap) { @@ -3402,7 +3402,7 @@ void DesktopLOKTest::testRenderSearchResult_CommonNode() CPPUNIT_ASSERT_EQUAL(size_t(73728), nByteSize); const sal_uInt8* pD = reinterpret_cast<const sal_uInt8*>(pBuffer); - BitmapEx aBitmap = vcl::bitmap::CreateFromData(pD, nWidth, nHeight, nWidth * 4, vcl::PixelFormat::N32_BPP, true, true); + BitmapEx aBitmap = vcl::bitmap::CreateFromData(pD, nWidth, nHeight, nWidth * 4, /*nBitsPerPixel*/32, true, true); if (bDumpBitmap) { diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx index 4790465a7366..3a06f6423665 100644 --- a/drawinglayer/source/tools/wmfemfhelper.cxx +++ b/drawinglayer/source/tools/wmfemfhelper.cxx @@ -642,7 +642,7 @@ namespace wmfemfhelper }; Bitmap aMask(rBitmap.CreateMask(aWhite)); - Bitmap aSolid(rBitmap.GetSizePixel(), vcl::PixelFormat::N1_BPP, &aBiLevelPalette); + Bitmap aSolid(rBitmap.GetSizePixel(), vcl::PixelFormat::N8_BPP, &aBiLevelPalette); aSolid.Erase(rMaskColor); diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 8825fa5fdea1..cfb15cd31eac 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -837,8 +837,8 @@ namespace emfio SAL_WARN("emfio", "\t\t TODO The unsupported Bitmap record. Please fill a bug."); break; } - const vcl::PixelFormat ePixelFormat = vcl::bitDepthToPixelFormat( nBitCount ); - bool bOk = nWidth > 0 && nHeight > 0 && nBytesPerScan > 0 && ePixelFormat != vcl::PixelFormat::INVALID; + bool bOk = nWidth > 0 && nHeight > 0 && nBytesPerScan > 0 + && (nBitCount == 1 || nBitCount == 8 || nBitCount == 24 || nBitCount == 32); if (bOk) { // must be enough data to fulfil the request @@ -854,7 +854,7 @@ namespace emfio std::unique_ptr< sal_uInt8[] > pData; pData.reset( new sal_uInt8[ nHeight * nBytesPerScan ] ); mpInputStream->ReadBytes( pData.get(), nHeight * nBytesPerScan ); - BitmapEx aBitmap = vcl::bitmap::CreateFromData( pData.get(), nWidth, nHeight, nBytesPerScan, ePixelFormat, true ); + BitmapEx aBitmap = vcl::bitmap::CreateFromData( pData.get(), nWidth, nHeight, nBytesPerScan, nBitCount, true ); if ( nSye && nSxe && ( nXSrc + nSxe <= nWidth ) && ( nYSrc + nSye <= nHeight ) ) diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index cdcad2778f6f..552deee7df5f 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -1412,7 +1412,7 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co Bitmap aBmp( aGraf.GetBitmapEx().GetBitmap() ); if (aBmp.GetSizePixel().Width() == 8 && aBmp.GetSizePixel().Height() == 8 && - aBmp.getPixelFormat() == vcl::PixelFormat::N1_BPP) + aBmp.getPixelFormat() == vcl::PixelFormat::N8_BPP) { Color aCol1( COL_WHITE ), aCol2( COL_WHITE ); diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx index ccdd28e0df95..a496f5bb4aa5 100644 --- a/forms/source/component/imgprod.cxx +++ b/forms/source/component/imgprod.cxx @@ -377,7 +377,7 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic ) if( !pMskAcc ) { - aMask = Bitmap(aBmp.GetSizePixel(), vcl::PixelFormat::N1_BPP); + aMask = Bitmap(aBmp.GetSizePixel(), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); aMask.Erase( COL_BLACK ); pMskAcc = aMask.AcquireReadAccess(); } diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx index d43e9dc7a692..f06f736e452c 100644 --- a/include/vcl/BitmapTools.hxx +++ b/include/vcl/BitmapTools.hxx @@ -52,7 +52,7 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx, */ BitmapEx VCL_DLLPUBLIC CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, - vcl::PixelFormat ePixelFormat, + sal_Int8 nBitsPerPixel, bool bReversColors = false, bool bReverseAlpha = false); BitmapEx VCL_DLLPUBLIC CreateFromData( RawBitmap && data ); diff --git a/include/vcl/bitmap/BitmapTypes.hxx b/include/vcl/bitmap/BitmapTypes.hxx index 10d0f5332c7b..6f1cc220a977 100644 --- a/include/vcl/bitmap/BitmapTypes.hxx +++ b/include/vcl/bitmap/BitmapTypes.hxx @@ -19,7 +19,6 @@ namespace vcl enum class PixelFormat { INVALID = 0, - N1_BPP = 1, N8_BPP = 8, N24_BPP = 24, N32_BPP = 32 @@ -47,9 +46,8 @@ constexpr PixelFormat bitDepthToPixelFormat(sal_uInt16 nBitDepth) switch (nBitDepth) { case 1: - return PixelFormat::N1_BPP; case 4: - assert(false); + assert(false && "no longer supported"); break; case 8: return PixelFormat::N8_BPP; diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx index 72cb9822cddb..2c2fcf109504 100644 --- a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx +++ b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx @@ -114,7 +114,7 @@ std::unique_ptr<XFBGImage> LwpBackgroundStuff::GetFillPattern() GetPattern(m_nID, aPttnArray); // create bitmap object from the pattern array - BitmapEx aBmp = vcl::bitmap::CreateFromData(aPttnArray, 8, 8, 1, vcl::PixelFormat::N1_BPP); + BitmapEx aBmp = vcl::bitmap::CreateFromData(aPttnArray, 8, 8, 1, /*nBitsPerPixel*/ 8); // create XOBitmap object from bitmap object XOBitmap aXOBitmap(aBmp); diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx index 44362b9a78ec..f083ad85bb78 100644 --- a/svx/source/gallery2/galobj.cxx +++ b/svx/source/gallery2/galobj.cxx @@ -313,7 +313,7 @@ SgaObjectSound::SgaObjectSound( const INetURLObject& rURL ) : if( FileExists( rURL ) ) { aURL = rURL; - aThumbBmp = Bitmap(Size(1, 1), vcl::PixelFormat::N1_BPP); + aThumbBmp = Bitmap(Size(1, 1), vcl::PixelFormat::N8_BPP); bIsValid = true; } else diff --git a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx index 6376fa796086..ff733c0b6e53 100644 --- a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx +++ b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx @@ -51,7 +51,7 @@ namespace drawinglayer::primitive2d r, g, b, 0, r, g, b, 0, r, g, b, 0, 0, 0, 0, a, r, g, b, 0, 0, 0, 0, a }; - BitmapEx aBitmap = vcl::bitmap::CreateFromData(cross, 3, 3, 12, vcl::PixelFormat::N32_BPP); + BitmapEx aBitmap = vcl::bitmap::CreateFromData(cross, 3, 3, 12, /*nBitsPerPixel*/32); // create and exchange at aRetVal aRetVal.set(aBitmap); diff --git a/vcl/headless/BitmapHelper.cxx b/vcl/headless/BitmapHelper.cxx index 35bcad3fe304..3eb29aa76ad3 100644 --- a/vcl/headless/BitmapHelper.cxx +++ b/vcl/headless/BitmapHelper.cxx @@ -82,46 +82,23 @@ MaskHelper::MaskHelper(const SalBitmap& rAlphaBitmap) { const SvpSalBitmap& rMask = static_cast<const SvpSalBitmap&>(rAlphaBitmap); const BitmapBuffer* pMaskBuf = rMask.GetBuffer(); - - if (rAlphaBitmap.GetBitCount() == 8) - { - // the alpha values need to be inverted for Cairo - // so big stupid copy and invert here - const int nImageSize = pMaskBuf->mnHeight * pMaskBuf->mnScanlineSize; - pAlphaBits.reset(new unsigned char[nImageSize]); - memcpy(pAlphaBits.get(), pMaskBuf->mpBits, nImageSize); - - // TODO: make upper layers use standard alpha - sal_uInt32* pLDst = reinterpret_cast<sal_uInt32*>(pAlphaBits.get()); - for (int i = nImageSize / sizeof(sal_uInt32); --i >= 0; ++pLDst) - *pLDst = ~*pLDst; - assert(reinterpret_cast<unsigned char*>(pLDst) == pAlphaBits.get() + nImageSize); - - implSetSurface(cairo_image_surface_create_for_data(pAlphaBits.get(), CAIRO_FORMAT_A8, - pMaskBuf->mnWidth, pMaskBuf->mnHeight, - pMaskBuf->mnScanlineSize)); - } - else - { - // the alpha values need to be inverted for Cairo - // so big stupid copy and invert here - const int nImageSize = pMaskBuf->mnHeight * pMaskBuf->mnScanlineSize; - pAlphaBits.reset(new unsigned char[nImageSize]); - memcpy(pAlphaBits.get(), pMaskBuf->mpBits, nImageSize); - - const sal_Int32 nBlackIndex = pMaskBuf->maPalette.GetBestIndex(BitmapColor(COL_BLACK)); - if (nBlackIndex == 0) - { - // TODO: make upper layers use standard alpha - unsigned char* pDst = pAlphaBits.get(); - for (int i = nImageSize; --i >= 0; ++pDst) - *pDst = ~*pDst; - } - - implSetSurface(cairo_image_surface_create_for_data(pAlphaBits.get(), CAIRO_FORMAT_A1, - pMaskBuf->mnWidth, pMaskBuf->mnHeight, - pMaskBuf->mnScanlineSize)); - } + assert(rAlphaBitmap.GetBitCount() == 8 && "we only support 8-bit masks now"); + + // the alpha values need to be inverted for Cairo + // so big stupid copy and invert here + const int nImageSize = pMaskBuf->mnHeight * pMaskBuf->mnScanlineSize; + pAlphaBits.reset(new unsigned char[nImageSize]); + memcpy(pAlphaBits.get(), pMaskBuf->mpBits, nImageSize); + + // TODO: make upper layers use standard alpha + sal_uInt32* pLDst = reinterpret_cast<sal_uInt32*>(pAlphaBits.get()); + for (int i = nImageSize / sizeof(sal_uInt32); --i >= 0; ++pLDst) + *pLDst = ~*pLDst; + assert(reinterpret_cast<unsigned char*>(pLDst) == pAlphaBits.get() + nImageSize); + + implSetSurface(cairo_image_surface_create_for_data(pAlphaBits.get(), CAIRO_FORMAT_A8, + pMaskBuf->mnWidth, pMaskBuf->mnHeight, + pMaskBuf->mnScanlineSize)); } namespace diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 0aaefff4ef52..90f10bfdaa25 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1771,9 +1771,10 @@ std::shared_ptr<SalBitmap> CairoCommon::getBitmap(tools::Long nX, tools::Long nY std::shared_ptr<SvpSalBitmap> pBitmap = std::make_shared<SvpSalBitmap>(); BitmapPalette aPal; vcl::PixelFormat ePixelFormat = vcl::PixelFormat::INVALID; + assert(GetBitCount() != 1 && "not supported anymore"); if (GetBitCount() == 1) { - ePixelFormat = vcl::PixelFormat::N1_BPP; + ePixelFormat = vcl::PixelFormat::N8_BPP; aPal.SetEntryCount(2); aPal[0] = COL_BLACK; aPal[1] = COL_WHITE; diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index a72774068d30..9c12fb91d2c1 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -64,9 +64,6 @@ static std::unique_ptr<BitmapBuffer> ImplCreateDIB( switch (ePixelFormat) { - case vcl::PixelFormat::N1_BPP: - pDIB->mnFormat = ScanlineFormat::N1BitLsbPal; - break; case vcl::PixelFormat::N8_BPP: pDIB->mnFormat = ScanlineFormat::N8BitPal; break; diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx index 669b5bef6df0..694a0756d9f7 100644 --- a/vcl/inc/qt5/QtTools.hxx +++ b/vcl/inc/qt5/QtTools.hxx @@ -111,8 +111,6 @@ inline QImage::Format getBitFormat(vcl::PixelFormat ePixelFormat) { switch (ePixelFormat) { - case vcl::PixelFormat::N1_BPP: - return QImage::Format_Mono; case vcl::PixelFormat::N8_BPP: return QImage::Format_Indexed8; case vcl::PixelFormat::N24_BPP: diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index 79f779f2a809..98fabd569f24 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -94,19 +94,6 @@ void BitmapTest::testCreation() } { - Bitmap aBmp(Size(10, 10), vcl::PixelFormat::N1_BPP); - Size aSize = aBmp.GetSizePixel(); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong width", static_cast<tools::Long>(10), aSize.Width()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height", static_cast<tools::Long>(10), aSize.Height()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pref size", Size(), aBmp.GetPrefSize()); - CPPUNIT_ASSERT_MESSAGE("Empty bitmap", !aBmp.IsEmpty()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong pixel format", vcl::PixelFormat::N1_BPP, - aBmp.getPixelFormat()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong byte size", static_cast<sal_Int64>(12), - aBmp.GetSizeBytes()); - } - - { Bitmap aBmp(Size(10, 10), vcl::PixelFormat::N8_BPP); Size aSize = aBmp.GetSizePixel(); CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong width", static_cast<tools::Long>(10), aSize.Width()); diff --git a/vcl/qa/cppunit/BmpFilterTest.cxx b/vcl/qa/cppunit/BmpFilterTest.cxx index 1ab7bc2a0a4a..7a4987116a67 100644 --- a/vcl/qa/cppunit/BmpFilterTest.cxx +++ b/vcl/qa/cppunit/BmpFilterTest.cxx @@ -100,7 +100,7 @@ CPPUNIT_TEST_FIXTURE(BmpFilterTest, testBMP_Index_1BPP) auto aBitmap = aGraphic.GetBitmapEx(); CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(4), aBitmap.GetSizePixel().Height()); - CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N1_BPP, aBitmap.getPixelFormat()); + CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, aBitmap.getPixelFormat()); CPPUNIT_ASSERT_EQUAL(COL_BLACK, aBitmap.GetPixelColor(0, 0)); CPPUNIT_ASSERT_EQUAL(COL_BLACK, aBitmap.GetPixelColor(0, 2)); diff --git a/vcl/qa/cppunit/XpmFilterTest.cxx b/vcl/qa/cppunit/XpmFilterTest.cxx index 1c24de1e131e..e9358d755f90 100644 --- a/vcl/qa/cppunit/XpmFilterTest.cxx +++ b/vcl/qa/cppunit/XpmFilterTest.cxx @@ -66,7 +66,7 @@ CPPUNIT_TEST_FIXTURE(XpmFilterTest, testXPM_1bit) auto aBitmap = aGraphic.GetBitmapEx(); CPPUNIT_ASSERT_EQUAL(tools::Long(10), aBitmap.GetSizePixel().Width()); CPPUNIT_ASSERT_EQUAL(tools::Long(10), aBitmap.GetSizePixel().Height()); - CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N1_BPP, aBitmap.getPixelFormat()); + CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N8_BPP, aBitmap.getPixelFormat()); CPPUNIT_ASSERT_EQUAL(Color(0xffffff), aBitmap.GetPixelColor(0, 0)); CPPUNIT_ASSERT_EQUAL(Color(0x72d1c8), aBitmap.GetPixelColor(1, 1)); CPPUNIT_ASSERT_EQUAL(Color(0x72d1c8), aBitmap.GetPixelColor(8, 8)); diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx index d16401b46464..32481620d2dc 100644 --- a/vcl/qa/cppunit/canvasbitmaptest.cxx +++ b/vcl/qa/cppunit/canvasbitmaptest.cxx @@ -640,7 +640,6 @@ void CanvasBitmapTest::runTest() { static vcl::PixelFormat ePixelFormatArray[] = { - vcl::PixelFormat::N1_BPP, vcl::PixelFormat::N8_BPP, vcl::PixelFormat::N24_BPP }; diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx b/vcl/qa/cppunit/png/PngFilterTest.cxx index 81bafac1d184..fd5747d8e9c8 100644 --- a/vcl/qa/cppunit/png/PngFilterTest.cxx +++ b/vcl/qa/cppunit/png/PngFilterTest.cxx @@ -175,7 +175,6 @@ public: void testPngRoundtrip24(); void testPngRoundtrip24_8(); void testPngRoundtrip32(); - void testPngWrite1BitRGBPalette(); void testPngWrite8BitRGBPalette(); CPPUNIT_TEST_SUITE(PngFilterTest); @@ -186,7 +185,6 @@ public: CPPUNIT_TEST(testPngRoundtrip24); CPPUNIT_TEST(testPngRoundtrip24_8); CPPUNIT_TEST(testPngRoundtrip32); - CPPUNIT_TEST(testPngWrite1BitRGBPalette); CPPUNIT_TEST(testPngWrite8BitRGBPalette); CPPUNIT_TEST_SUITE_END(); }; @@ -1912,69 +1910,6 @@ void PngFilterTest::testPngRoundtrip24_8() void PngFilterTest::testPngRoundtrip32() {} -void PngFilterTest::testPngWrite1BitRGBPalette() -{ - SvMemoryStream aExportStream; - { - BitmapPalette aPal; - aPal.SetEntryCount(2); - aPal[0] = COL_RED; - aPal[1] = COL_GREEN; - Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N1_BPP, &aPal); - { - BitmapScopedWriteAccess pWriteAccessBitmap(aBitmap); - // Top left - for (int i = 0; i < 8; i++) - { - for (int j = 0; j < 8; j++) - { - pWriteAccessBitmap->SetPixelIndex(i, j, 0); - } - } - // Top right - for (int i = 0; i < 8; i++) - { - for (int j = 8; j < 16; j++) - { - pWriteAccessBitmap->SetPixelIndex(i, j, 1); - } - } - // Bottom left - for (int i = 8; i < 16; i++) - { - for (int j = 0; j < 8; j++) - { - pWriteAccessBitmap->SetPixelIndex(i, j, 1); - } - } - // Bottom right - for (int i = 8; i < 16; i++) - { - for (int j = 8; j < 16; j++) - { - pWriteAccessBitmap->SetPixelIndex(i, j, 0); - } - } - } - BitmapEx aBitmapEx(aBitmap); - vcl::PngImageWriter aPngWriter(aExportStream); - CPPUNIT_ASSERT_EQUAL(true, aPngWriter.write(aBitmapEx)); - } - aExportStream.Seek(0); - { - vcl::PngImageReader aPngReader(aExportStream); - BitmapEx aBitmapEx; - CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx)); - - CPPUNIT_ASSERT_EQUAL(Size(16, 16), aBitmapEx.GetSizePixel()); - - CPPUNIT_ASSERT_EQUAL(COL_RED, aBitmapEx.GetPixelColor(0, 0)); - CPPUNIT_ASSERT_EQUAL(COL_RED, aBitmapEx.GetPixelColor(15, 15)); - CPPUNIT_ASSERT_EQUAL(COL_GREEN, aBitmapEx.GetPixelColor(15, 0)); - CPPUNIT_ASSERT_EQUAL(COL_GREEN, aBitmapEx.GetPixelColor(0, 15)); - } -} - void PngFilterTest::testPngWrite8BitRGBPalette() { SvMemoryStream aExportStream; diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx index 3c92ea3d7d7f..02cec9bcfd45 100644 --- a/vcl/qa/cppunit/svm/svmtest.cxx +++ b/vcl/qa/cppunit/svm/svmtest.cxx @@ -116,7 +116,7 @@ class SvmTest : public test::BootstrapFixture, public XmlTestTools void checkBitmaps(const GDIMetaFile& rMetaFile); void testBitmaps(); - void checkBitmapExs(const GDIMetaFile& rMetaFile); + void checkBitmapExs(const GDIMetaFile& rMetaFile, bool bIsSvmFile); void testBitmapExs(); void checkMasks(const GDIMetaFile& rMetaFile); @@ -998,7 +998,7 @@ void SvmTest::testBitmaps() } } -void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile) +void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile, bool bIsSvmFile) { xmlDocUniquePtr pDoc = dumpMeta(rMetaFile); @@ -1013,7 +1013,7 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile) "281fc589", "b8dee5da", "4df0e464", - "186ff868", + "186ff868", // 1-bit "33b4a07c", // 4-bit color bitmap - same as 8-bit color bitmap "33b4a07c", "742c3e35", @@ -1022,7 +1022,7 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile) "281fc589", "5e01ddcc", "4df0e464", - "4322ee3a", + "17df308f", // 1-bit "3c80d829", // 4-bit color bitmap - same as 8-bit color bitmap "3c80d829", "71efc447", @@ -1046,9 +1046,12 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile) assertXPathAttrs(pDoc, "/metafile/bmpex[2]", { {"x", "6"}, {"y", "6"}, {"crc", aExpectedCRC[3]}, {"transparenttype", "bitmap"} }); - assertXPathAttrs(pDoc, "/metafile/bmpex[3]", { - {"x", "0"}, {"y", "6"}, {"crc", aExpectedCRC[4]}, {"transparenttype", "bitmap"} - }); + if (!bIsSvmFile) + { + assertXPathAttrs(pDoc, "/metafile/bmpex[3]", { + {"x", "0"}, {"y", "6"}, {"crc", aExpectedCRC[4]}, {"transparenttype", "bitmap"} + }); + } assertXPathAttrs(pDoc, "/metafile/bmpex[4]", { {"x", "2"}, {"y", "6"}, {"crc", aExpectedCRC[5]}, {"transparenttype", "bitmap"} }); @@ -1058,6 +1061,8 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& rMetaFile) assertXPathAttrs(pDoc, "/metafile/bmpex[6]", { {"x", "2"}, {"y", "8"}, {"crc", aExpectedCRC[7]}, {"transparenttype", "bitmap"} }); +#else + (void)bIsSvmFile; #endif } @@ -1158,12 +1163,12 @@ void SvmTest::testBitmapExs() { GDIMetaFile aReloadedGDIMetaFile = writeAndReadStream(aGDIMetaFile); - checkBitmapExs(aReloadedGDIMetaFile); + checkBitmapExs(aReloadedGDIMetaFile, /*bIsSvmFile*/false); checkRendering(pVirtualDev, aReloadedGDIMetaFile); } { GDIMetaFile aFileGDIMetaFile = readFile(u"bitmapexs.svm"); - checkBitmapExs(aFileGDIMetaFile); + checkBitmapExs(aFileGDIMetaFile, /*bIsSvmFile*/true); checkRendering(pVirtualDev, aFileGDIMetaFile); } } diff --git a/vcl/qt5/QtBitmap.cxx b/vcl/qt5/QtBitmap.cxx index 666cb673db65..dd83c57c23a5 100644 --- a/vcl/qt5/QtBitmap.cxx +++ b/vcl/qt5/QtBitmap.cxx @@ -38,8 +38,6 @@ bool QtBitmap::Create(const Size& rSize, vcl::PixelFormat ePixelFormat, const Bi if (ePixelFormat == vcl::PixelFormat::INVALID) return false; - if (ePixelFormat == vcl::PixelFormat::N1_BPP) - assert(2 >= rPal.GetEntryCount()); if (ePixelFormat == vcl::PixelFormat::N8_BPP) assert(256 >= rPal.GetEntryCount()); diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx index 3a07dd61da07..cf50c1976c3a 100644 --- a/vcl/source/bitmap/BitmapEx.cxx +++ b/vcl/source/bitmap/BitmapEx.cxx @@ -113,12 +113,11 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ) : if( rMask.getPixelFormat() == vcl::PixelFormat::N8_BPP && rMask.HasGreyPalette8Bit() ) maAlphaMask = rMask; - else if (rMask.getPixelFormat() == vcl::PixelFormat::N1_BPP) + else if( rMask.getPixelFormat() == vcl::PixelFormat::N8_BPP ) { - // convert 1-bit mask to alpha bitmap - BitmapEx aBmpEx(rMask); - BitmapFilter::Filter(aBmpEx, BitmapMaskToAlphaFilter()); - maAlphaMask = aBmpEx.GetBitmap(); + BitmapEx aMaskEx(rMask); + BitmapFilter::Filter(aMaskEx, BitmapMonochromeFilter(255)); + maAlphaMask = aMaskEx.GetBitmap(); } else { @@ -126,7 +125,6 @@ BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ) : SAL_WARN( "vcl", "BitmapEx: forced mask to monochrome"); BitmapEx aMaskEx(rMask); BitmapFilter::Filter(aMaskEx, BitmapMonochromeFilter(255)); - BitmapFilter::Filter(aMaskEx, BitmapMaskToAlphaFilter()); maAlphaMask = aMaskEx.GetBitmap(); } diff --git a/vcl/source/bitmap/BitmapMonochromeFilter.cxx b/vcl/source/bitmap/BitmapMonochromeFilter.cxx index 5c294544aa1e..e45ae12fa6d0 100644 --- a/vcl/source/bitmap/BitmapMonochromeFilter.cxx +++ b/vcl/source/bitmap/BitmapMonochromeFilter.cxx @@ -21,7 +21,7 @@ BitmapEx BitmapMonochromeFilter::execute(BitmapEx const& aBitmapEx) const if (!pReadAcc) return BitmapEx(); - Bitmap aNewBmp(aBitmap.GetSizePixel(), vcl::PixelFormat::N1_BPP); + Bitmap aNewBmp(aBitmap.GetSizePixel(), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); BitmapScopedWriteAccess pWriteAcc(aNewBmp); if (!pWriteAcc) return BitmapEx(); diff --git a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx index 97511ed323b6..38e2c76794b0 100644 --- a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx +++ b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx @@ -28,11 +28,7 @@ BitmapEx BitmapSimpleColorQuantizationFilter::execute(BitmapEx const& aBitmapEx) return BitmapEx(); const sal_uInt16 nColorCount = std::min(mnNewColorCount, sal_uInt16(256)); - auto ePixelFormat = vcl::PixelFormat::INVALID; - if (nColorCount <= 2) - ePixelFormat = vcl::PixelFormat::N1_BPP; - else - ePixelFormat = vcl::PixelFormat::N8_BPP; + auto ePixelFormat = vcl::PixelFormat::N8_BPP; Octree aOct(*pRAcc, nColorCount); const BitmapPalette& rPal = aOct.GetPalette(); diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index 4628e012abb0..7c19c237d57f 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -130,15 +130,31 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx, In case the endianness of pData is wrong, you could reverse colors */ BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, - sal_Int32 nStride, vcl::PixelFormat ePixelFormat, + sal_Int32 nStride, sal_Int8 nBitCount, bool bReversColors, bool bReverseAlpha) { - auto nBitCount = sal_uInt16(ePixelFormat); - assert(nStride >= (nWidth * nBitCount / 8)); - assert(nBitCount == 1 || nBitCount == 24 || nBitCount == 32); + assert(nBitCount == 1 || nBitCount == 8 || nBitCount == 24 || nBitCount == 32); - Bitmap aBmp(Size(nWidth, nHeight), ePixelFormat); + PixelFormat ePixelFormat; + if (nBitCount == 1) + ePixelFormat = PixelFormat::N8_BPP; // we convert 1-bit input data to 8-bit format + else if (nBitCount == 8) + ePixelFormat = PixelFormat::N8_BPP; + else if (nBitCount == 24) + ePixelFormat = PixelFormat::N24_BPP; + else if (nBitCount == 32) + ePixelFormat = PixelFormat::N32_BPP; + else + std::abort(); + Bitmap aBmp; + if (nBitCount == 1) + { + BitmapPalette aBiLevelPalette { COL_BLACK, COL_WHITE }; + aBmp = Bitmap(Size(nWidth, nHeight), PixelFormat::N8_BPP, &aBiLevelPalette); + } + else + aBmp = Bitmap(Size(nWidth, nHeight), ePixelFormat); BitmapScopedWriteAccess pWrite(aBmp); assert(pWrite.get()); @@ -174,7 +190,9 @@ BitmapEx CreateFromData(sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHei for (tools::Long x = 0; x < nWidth; ++x) { BitmapColor col; - if ( bReversColors ) + if (nBitCount == 8) + col = BitmapColor( *p ); + else if ( bReversColors ) col = BitmapColor( p[2], p[1], p[0] ); else col = BitmapColor( p[0], p[1], p[2] ); @@ -1032,7 +1050,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un aPalette[0] = BitmapColor(aColorBack); aPalette[1] = BitmapColor(aColorPix); - Bitmap aBitmap(Size(8, 8), vcl::PixelFormat::N1_BPP, &aPalette); + Bitmap aBitmap(Size(8, 8), vcl::PixelFormat::N8_BPP, &aPalette); BitmapScopedWriteAccess pContent(aBitmap); for(sal_uInt16 a(0); a < 8; a++) @@ -1063,58 +1081,37 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un if(8 == aBitmap.GetSizePixel().Width() && 8 == aBitmap.GetSizePixel().Height()) { - if (aBitmap.getPixelFormat() == vcl::PixelFormat::N1_BPP) - { - BitmapReadAccess* pRead = aBitmap.AcquireReadAccess(); - - if(pRead) + // Historical 1bpp images are getting really historical, + // even to the point that e.g. the png loader actually loads + // them as RGB. But the pattern code in svx relies on this + // assumption that any 2-color 1bpp bitmap is a pattern, and so it would + // get confused by RGB. Try to detect if this image is really + // just two colors and say it's a pattern bitmap if so. + Bitmap::ScopedReadAccess access(aBitmap); + o_rBack = access->GetColor(0,0); + bool foundSecondColor = false;; + for(tools::Long y = 0; y < access->Height(); ++y) + for(tools::Long x = 0; x < access->Width(); ++x) { - if(pRead->HasPalette() && 2 == pRead->GetPaletteEntryCount()) + if(!foundSecondColor) { - const BitmapPalette& rPalette = pRead->GetPalette(); - o_rFront = rPalette[1]; - o_rBack = rPalette[0]; - - bRet = true; - } - - Bitmap::ReleaseAccess(pRead); - } - } - else - { - // Historical 1bpp images are getting really historical, - // even to the point that e.g. the png loader actually loads - // them as RGB. But the pattern code in svx relies on this - // assumption that any 2-color 1bpp bitmap is a pattern, and so it would - // get confused by RGB. Try to detect if this image is really - // just two colors and say it's a pattern bitmap if so. - Bitmap::ScopedReadAccess access(aBitmap); - o_rBack = access->GetColor(0,0); - bool foundSecondColor = false;; - for(tools::Long y = 0; y < access->Height(); ++y) - for(tools::Long x = 0; x < access->Width(); ++x) - { - if(!foundSecondColor) - { - if( access->GetColor(y,x) != o_rBack ) - { - o_rFront = access->GetColor(y,x); - foundSecondColor = true; - // Hard to know which of the two colors is the background, - // select the lighter one. - if( o_rFront.GetLuminance() > o_rBack.GetLuminance()) - std::swap( o_rFront, o_rBack ); - } - } - else + if( access->GetColor(y,x) != o_rBack ) { - if( access->GetColor(y,x) != o_rBack && access->GetColor(y,x) != o_rFront) - return false; + o_rFront = access->GetColor(y,x); + foundSecondColor = true; + // Hard to know which of the two colors is the background, + // select the lighter one. + if( o_rFront.GetLuminance() > o_rBack.GetLuminance()) + std::swap( o_rFront, o_rBack ); } } - return true; - } + else + { + if( access->GetColor(y,x) != o_rBack && access->GetColor(y,x) != o_rFront) + return false; + } + } + return true; } } diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx index fb73e4bb0d48..8214b266b640 100644 --- a/vcl/source/bitmap/bitmap.cxx +++ b/vcl/source/bitmap/bitmap.cxx @@ -82,13 +82,6 @@ Bitmap::Bitmap( const Size& rSizePixel, vcl::PixelFormat ePixelFormat, const Bit switch (ePixelFormat) { - case vcl::PixelFormat::N1_BPP: - { - static const BitmapPalette aPalN1_BPP = { COL_BLACK, COL_WHITE }; - if (!pPal) - pPal = &aPalN1_BPP; - break; - } case vcl::PixelFormat::N8_BPP: { static const BitmapPalette aPalN8_BPP = [] { @@ -268,8 +261,6 @@ vcl::PixelFormat Bitmap::getPixelFormat() const return vcl::PixelFormat::INVALID; sal_uInt16 nBitCount = mxSalBmp->GetBitCount(); - if (nBitCount <= 1) - return vcl::PixelFormat::N1_BPP; if (nBitCount <= 8) return vcl::PixelFormat::N8_BPP; if (nBitCount <= 24) @@ -282,7 +273,7 @@ vcl::PixelFormat Bitmap::getPixelFormat() const bool Bitmap::HasGreyPaletteAny() const { - bool bRet = getPixelFormat() == vcl::PixelFormat::N1_BPP; + bool bRet = false; ScopedInfoAccess pIAcc(const_cast<Bitmap&>(*this)); @@ -1299,22 +1290,6 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag n } } - // 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 - // - // 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 (eStartPixelFormat == vcl::PixelFormat::N1_BPP) - nScaleFlag = BmpScaleFlag::Fast; - BitmapEx aBmpEx(*this); bool bRetval(false); @@ -1391,11 +1366,6 @@ void Bitmap::AdaptBitCount(Bitmap& rNew) const switch (getPixelFormat()) { - case vcl::PixelFormat::N1_BPP: - { - rNew.Convert(BmpConversion::N1BitThreshold); - break; - } case vcl::PixelFormat::N8_BPP: { if(HasGreyPaletteAny()) diff --git a/vcl/source/bitmap/bitmappaint.cxx b/vcl/source/bitmap/bitmappaint.cxx index e13e222699a5..388dbe89c57b 100644 --- a/vcl/source/bitmap/bitmappaint.cxx +++ b/vcl/source/bitmap/bitmappaint.cxx @@ -837,11 +837,6 @@ bool Bitmap::Replace(const Color& rSearchColor, const Color& rReplaceColor, sal_ } } - // Bitmaps with 1 bit color depth can cause problems if they have other entries than black/white - // in their palette - if (getPixelFormat() == vcl::PixelFormat::N1_BPP) - Convert(BmpConversion::N8BitColors); - BitmapScopedWriteAccess pAcc(*this); bool bRet = false; @@ -900,11 +895,6 @@ bool Bitmap::Replace(const Color& rSearchColor, const Color& rReplaceColor, sal_ bool Bitmap::Replace(const Color* pSearchColors, const Color* pReplaceColors, size_t nColorCount, sal_uInt8 const* pTols) { - // Bitmaps with 1 bit color depth can cause problems if they have other entries than black/white - // in their palette - if (getPixelFormat() == vcl::PixelFormat::N1_BPP) - Convert(BmpConversion::N8BitColors); - BitmapScopedWriteAccess pAcc(*this); bool bRet = false; diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx index e2e9076c5ddb..6bf360d7c861 100644 --- a/vcl/source/bitmap/dibtools.cxx +++ b/vcl/source/bitmap/dibtools.cxx @@ -133,8 +133,7 @@ struct DIBV5Header : public DIBInfoHeader vcl::PixelFormat convertToBPP(sal_uInt16 nCount) { - return (nCount <= 1) ? vcl::PixelFormat::N1_BPP : - (nCount <= 8) ? vcl::PixelFormat::N8_BPP : + return (nCount <= 8) ? vcl::PixelFormat::N8_BPP : vcl::PixelFormat::N24_BPP; } @@ -358,7 +357,7 @@ BitmapColor SanitizeColor(const BitmapColor &rColor, bool bForceToMonoWhileReadi return BitmapColor(static_cast<sal_uInt8>(rColor.GetLuminance() >= 255)); } -bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteAccess& rAcc, BitmapPalette& rPalette, bool bForceToMonoWhileReading, bool bRLE4) +bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteAccess& rAcc, BitmapPalette& rPalette, bool bRLE4) { Scanline pRLE = pBuffer; Scanline pEndRLE = pBuffer + rHeader.nSizeImage; @@ -395,10 +394,10 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA cTmp = *pRLE++; if( nX < nWidth ) - rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, /*bForceToMonoWhileReading*/false)); if( nX < nWidth ) - rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp & 0x0f, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp & 0x0f, rPalette, /*bForceToMonoWhileReading*/false)); } if( nRunByte & 1 ) @@ -407,7 +406,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA return false; if( nX < nWidth ) - rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(*pRLE >> 4, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(*pRLE >> 4, rPalette, /*bForceToMonoWhileReading*/false)); pRLE++; } @@ -428,7 +427,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA return false; if( nX < nWidth ) - rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(*pRLE, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(*pRLE, rPalette, /*bForceToMonoWhileReading*/false)); pRLE++; } @@ -475,18 +474,18 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA for (sal_uLong i = 0; i < nRunByte && nX < nWidth; ++i) { - rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, /*bForceToMonoWhileReading*/false)); if( nX < nWidth ) - rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp & 0x0f, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp & 0x0f, rPalette, /*bForceToMonoWhileReading*/false)); } if( ( nCountByte & 1 ) && ( nX < nWidth ) ) - rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp >> 4, rPalette, /*bForceToMonoWhileReading*/false)); } else { for (sal_uLong i = 0; i < nCountByte && nX < nWidth; ++i) - rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX++, SanitizePaletteIndex(cTmp, rPalette, /*bForceToMonoWhileReading*/false)); } } } @@ -496,8 +495,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, BitmapWriteA } bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& rAcc, BitmapPalette& rPalette, BitmapWriteAccess* pAccAlpha, - bool bTopDown, bool& rAlphaUsed, const sal_uInt64 nAlignedWidth, - const bool bForceToMonoWhileReading) + bool bTopDown, bool& rAlphaUsed, const sal_uInt64 nAlignedWidth) { sal_uInt32 nRMask(( rHeader.nBitCount == 16 ) ? 0x00007c00UL : 0x00ff0000UL); sal_uInt32 nGMask(( rHeader.nBitCount == 16 ) ? 0x000003e0UL : 0x0000ff00UL); @@ -565,7 +563,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r std::vector<sal_uInt8> aBuffer(rHeader.nSizeImage); if (rIStm.ReadBytes(aBuffer.data(), rHeader.nSizeImage) != rHeader.nSizeImage) return false; - if (!ImplDecodeRLE(aBuffer.data(), rHeader, rAcc, rPalette, bForceToMonoWhileReading, RLE_4 == rHeader.nCompression)) + if (!ImplDecodeRLE(aBuffer.data(), rHeader, rAcc, rPalette, RLE_4 == rHeader.nCompression)) return false; } else @@ -607,7 +605,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r } auto nIndex = (cTmp >> --nShift) & 1; - rAcc.SetPixelOnData(pScanline, nX, SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX, SanitizePaletteIndex(nIndex, rPalette, /*bForceToMonoWhileReading*/false)); } } } @@ -634,7 +632,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r } auto nIndex = (cTmp >> ( --nShift << 2 ) ) & 0x0f; - rAcc.SetPixelOnData(pScanline, nX, SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX, SanitizePaletteIndex(nIndex, rPalette, /*bForceToMonoWhileReading*/false)); } } } @@ -655,7 +653,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r for( tools::Long nX = 0; nX < nWidth; nX++ ) { auto nIndex = *pTmp++; - rAcc.SetPixelOnData(pScanline, nX, SanitizePaletteIndex(nIndex, rPalette, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX, SanitizePaletteIndex(nIndex, rPalette, /*bForceToMonoWhileReading*/false)); } } } @@ -689,7 +687,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r for( tools::Long nX = 0; nX < nWidth; nX++ ) { aMask.GetColorFor16BitLSB( aColor, reinterpret_cast<sal_uInt8*>(pTmp16++) ); - rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, /*bForceToMonoWhileReading*/false)); } } } @@ -714,7 +712,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r aPixelColor.SetBlue( *pTmp++ ); aPixelColor.SetGreen( *pTmp++ ); aPixelColor.SetRed( *pTmp++ ); - rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aPixelColor, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aPixelColor, /*bForceToMonoWhileReading*/false)); } } } @@ -754,7 +752,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r for( tools::Long nX = 0; nX < nWidth; nX++ ) { aMask.GetColorAndAlphaFor32Bit( aColor, aAlpha, reinterpret_cast<sal_uInt8*>(pTmp32++) ); - rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, /*bForceToMonoWhileReading*/false)); pAccAlpha->SetPixelOnData(pAlphaScanline, nX, BitmapColor(sal_uInt8(0xff) - aAlpha)); rAlphaUsed |= 0xff != aAlpha; } @@ -775,7 +773,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r for( tools::Long nX = 0; nX < nWidth; nX++ ) { aMask.GetColorFor32Bit( aColor, reinterpret_cast<sal_uInt8*>(pTmp32++) ); - rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, bForceToMonoWhileReading)); + rAcc.SetPixelOnData(pScanline, nX, SanitizeColor(aColor, /*bForceToMonoWhileReading*/false)); } } } @@ -787,7 +785,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r return rIStm.GetError() == ERRCODE_NONE; } -bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uInt64 nOffset, bool bIsMask, bool bMSOFormat) +bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uInt64 nOffset, bool bMSOFormat) { DIBV5Header aHeader; const sal_uInt64 nStmPos = rIStm.Tell(); @@ -1011,15 +1009,6 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uI const BitmapPalette* pPal = &aPalette; //ofz#948 match the surrounding logic of case TransparentType::Bitmap of //ReadDIBBitmapEx but do it while reading for performance - const bool bIsAlpha = (ePixelFormat == vcl::PixelFormat::N8_BPP && - !!aPalette && aPalette.IsGreyPalette8Bit()); - const bool bForceToMonoWhileReading = (bIsMask && !bIsAlpha && ePixelFormat != vcl::PixelFormat::N1_BPP); - if (bForceToMonoWhileReading) - { - pPal = nullptr; - ePixelFormat = vcl::PixelFormat::N1_BPP; - SAL_WARN( "vcl", "forcing mask to monochrome"); - } Bitmap aNewBmp(aSizePixel, ePixelFormat, pPal); BitmapScopedWriteAccess pAcc(aNewBmp); @@ -1032,7 +1021,7 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uI // read bits bool bAlphaUsed(false); - bool bRet = ImplReadDIBBits(*pIStm, aHeader, *pAcc, aPalette, pAccAlpha.get(), bTopDown, bAlphaUsed, nAlignedWidth, bForceToMonoWhileReading); + bool bRet = ImplReadDIBBits(*pIStm, aHeader, *pAcc, aPalette, pAccAlpha.get(), bTopDown, bAlphaUsed, nAlignedWidth); if (bRet && aHeader.nXPelsPerMeter && aHeader.nYPelsPerMeter) { @@ -1330,36 +1319,6 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead std::vector<sal_uInt8> aBuf(nAlignedWidth); switch(ePixelFormat) { - case vcl::PixelFormat::N1_BPP: - { - //valgrind, zero out the trailing unused alignment bytes - size_t nUnusedBytes = nAlignedWidth - ((nWidth+7) / 8); - memset(aBuf.data() + nAlignedWidth - nUnusedBytes, 0, nUnusedBytes); - - for( tools::Long nY = nHeight - 1; nY >= 0; nY-- ) - { - sal_uInt8* pTmp = aBuf.data(); - sal_uInt8 cTmp = 0; - Scanline pScanline = rAcc.GetScanline( nY ); - - for( tools::Long nX = 0, nShift = 8; nX < nWidth; nX++ ) - { - if( !nShift ) - { - nShift = 8; - *pTmp++ = cTmp; - cTmp = 0; - } - - cTmp |= rAcc.GetIndexFromData( pScanline, nX ) << --nShift; - } - - *pTmp = cTmp; - rOStm.WriteBytes(aBuf.data(), nAlignedWidth); - } - } - break; - case vcl::PixelFormat::N8_BPP: { for( tools::Long nY = nHeight - 1; nY >= 0; nY-- ) @@ -1618,7 +1577,6 @@ bool ImplReadDIB( AlphaMask* pTargetAlpha, SvStream& rIStm, bool bFileHeader, - bool bIsMask=false, bool bMSOFormat=false) { const SvStreamEndian nOldFormat(rIStm.GetEndian()); @@ -1632,12 +1590,12 @@ bool ImplReadDIB( { if(ImplReadDIBFileHeader(rIStm, nOffset)) { - bRet = ImplReadDIBBody(rIStm, rTarget, nOffset >= DIBV5HEADERSIZE ? pTargetAlpha : nullptr, nOffset, bIsMask, bMSOFormat); + bRet = ImplReadDIBBody(rIStm, rTarget, nOffset >= DIBV5HEADERSIZE ? pTargetAlpha : nullptr, nOffset, bMSOFormat); } } else { - bRet = ImplReadDIBBody(rIStm, rTarget, nullptr, nOffset, bIsMask, bMSOFormat); + bRet = ImplReadDIBBody(rIStm, rTarget, nullptr, nOffset, bMSOFormat); } if(!bRet) @@ -1712,7 +1670,7 @@ bool ReadDIB( bool bFileHeader, bool bMSOFormat) { - return ImplReadDIB(rTarget, nullptr, rIStm, bFileHeader, false, bMSOFormat); + return ImplReadDIB(rTarget, nullptr, rIStm, bFileHeader, bMSOFormat); } bool ReadDIBBitmapEx( @@ -1722,7 +1680,7 @@ bool ReadDIBBitmapEx( bool bMSOFormat) { Bitmap aBmp; - bool bRetval(ImplReadDIB(aBmp, nullptr, rIStm, bFileHeader, /*bMask*/false, bMSOFormat) && !rIStm.GetError()); + bool bRetval(ImplReadDIB(aBmp, nullptr, rIStm, bFileHeader, bMSOFormat) && !rIStm.GetError()); if(bRetval) { @@ -1750,7 +1708,7 @@ bool ReadDIBBitmapEx( { Bitmap aMask; - bRetval = ImplReadDIB(aMask, nullptr, rIStm, true, true); + bRetval = ImplReadDIB(aMask, nullptr, rIStm, true); if(bRetval) { diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index 5e07db10415e..7cdc37710f51 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -219,7 +219,7 @@ void GIFReader::CreateBitmaps(tools::Long nWidth, tools::Long nHeight, BitmapPal { const Color aWhite(COL_WHITE); - aBmp1 = Bitmap(aSize, vcl::PixelFormat::N1_BPP); + aBmp1 = Bitmap(aSize, vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); if (!aAnimation.Count()) aBmp1.Erase(aWhite); diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx index 9368f9f9a885..7546d44f8681 100644 --- a/vcl/source/filter/ixbm/xbmread.cxx +++ b/vcl/source/filter/ixbm/xbmread.cxx @@ -330,7 +330,7 @@ ReadState XBMReader::ReadXBM( Graphic& rGraphic ) if ( bStatus && nWidth && nHeight ) { - aBmp1 = Bitmap(Size(nWidth, nHeight), vcl::PixelFormat::N1_BPP); + aBmp1 = Bitmap(Size(nWidth, nHeight), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); pAcc1 = BitmapScopedWriteAccess(aBmp1); if( pAcc1 ) @@ -349,7 +349,7 @@ ReadState XBMReader::ReadXBM( Graphic& rGraphic ) if (bStatus && pAcc1) { - Bitmap aBlackBmp(Size(pAcc1->Width(), pAcc1->Height()), vcl::PixelFormat::N1_BPP); + Bitmap aBlackBmp(Size(pAcc1->Width(), pAcc1->Height()), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); pAcc1.reset(); aBlackBmp.Erase( COL_BLACK ); diff --git a/vcl/source/filter/ixpm/xpmread.cxx b/vcl/source/filter/ixpm/xpmread.cxx index 2a979d2df238..a678f2316ad3 100644 --- a/vcl/source/filter/ixpm/xpmread.cxx +++ b/vcl/source/filter/ixpm/xpmread.cxx @@ -197,10 +197,8 @@ ReadState XPMReader::ReadXPM( Graphic& rGraphic ) auto ePixelFormat = vcl::PixelFormat::INVALID; if ( mnColors > 256 ) ePixelFormat = vcl::PixelFormat::N24_BPP; - else if ( mnColors > 2 ) - ePixelFormat = vcl::PixelFormat::N8_BPP; else - ePixelFormat = vcl::PixelFormat::N1_BPP; + ePixelFormat = vcl::PixelFormat::N8_BPP; maBmp = Bitmap(Size(mnWidth, mnHeight), ePixelFormat); mpAcc = BitmapScopedWriteAccess(maBmp); @@ -208,7 +206,7 @@ ReadState XPMReader::ReadXPM( Graphic& rGraphic ) // mbTransparent is TRUE if at least one colour is transparent if ( mbTransparent ) { - maMaskBmp = Bitmap(Size(mnWidth, mnHeight), vcl::PixelFormat::N1_BPP); + maMaskBmp = Bitmap(Size(mnWidth, mnHeight), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); mpMaskAcc = BitmapScopedWriteAccess(maMaskBmp); if ( !mpMaskAcc ) mbStatus = false; diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index c68ba88d7a16..f7443f3bfe9e 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -249,7 +249,7 @@ Graphic JPEGReader::CreateIntermediateGraphic(tools::Long nLines) if (!mnLastLines) { - mpIncompleteAlpha.reset(new Bitmap(aSizePixel, vcl::PixelFormat::N1_BPP)); + mpIncompleteAlpha.reset(new Bitmap(aSizePixel, vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256))); mpIncompleteAlpha->Erase(COL_WHITE); } diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx index 5319c2834686..d95578dbb9da 100644 --- a/vcl/source/gdi/mtfxmldump.cxx +++ b/vcl/source/gdi/mtfxmldump.cxx @@ -429,7 +429,6 @@ OUString convertPixelFormatToString(vcl::PixelFormat ePixelFormat) switch (ePixelFormat) { case vcl::PixelFormat::INVALID: return "INVALID"; - case vcl::PixelFormat::N1_BPP: return "1BPP"; case vcl::PixelFormat::N8_BPP: return "8BPP"; case vcl::PixelFormat::N24_BPP: return "24BPP"; case vcl::PixelFormat::N32_BPP: return "32BPP"; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index c0d85aa99878..e0f868d5d926 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -9209,9 +9209,12 @@ bool PDFWriterImpl::writeBitmapObject( const BitmapEmit& rObject, bool bMask ) { if( m_aContext.Version < PDFWriter::PDFVersion::PDF_1_4 || ! rObject.m_aBitmap.IsAlpha() ) { - aBitmap = getExportBitmap(rObject.m_aBitmap.GetAlphaMask()); - aBitmap.Convert( BmpConversion::N1BitThreshold ); - SAL_WARN_IF(aBitmap.getPixelFormat() != vcl::PixelFormat::N1_BPP, "vcl.pdfwriter", "mask conversion failed" ); + if( rObject.m_aBitmap.IsAlpha() ) + { + aBitmap = getExportBitmap(rObject.m_aBitmap.GetAlphaMask()); + aBitmap.Convert( BmpConversion::N1BitThreshold ); + SAL_WARN_IF(aBitmap.getPixelFormat() != vcl::PixelFormat::N8_BPP, "vcl.pdfwriter", "mask conversion failed" ); + } } else if (aBitmap.getPixelFormat() != vcl::PixelFormat::N8_BPP) { @@ -9228,7 +9231,6 @@ bool PDFWriterImpl::writeBitmapObject( const BitmapEmit& rObject, bool bMask ) auto const ePixelFormat = aBitmap.getPixelFormat(); switch (ePixelFormat) { - case vcl::PixelFormat::N1_BPP: case vcl::PixelFormat::N8_BPP: bTrueColor = false; nBitsPerComponent = vcl::pixelFormatBitCount(ePixelFormat); @@ -9282,7 +9284,7 @@ bool PDFWriterImpl::writeBitmapObject( const BitmapEmit& rObject, bool bMask ) else if( aBitmap.HasGreyPaletteAny() ) { aLine.append( "/DeviceGray\n" ); - if (aBitmap.getPixelFormat() == vcl::PixelFormat::N1_BPP) + if (aBitmap.getPixelFormat() == vcl::PixelFormat::N8_BPP) { // #i47395# 1 bit bitmaps occasionally have an inverted grey palette sal_uInt16 nBlackIndex = pAccess->GetBestPaletteIndex( BitmapColor( COL_BLACK ) ); @@ -9355,21 +9357,8 @@ bool PDFWriterImpl::writeBitmapObject( const BitmapEmit& rObject, bool bMask ) } else { - if (aBitmap.getPixelFormat() == vcl::PixelFormat::N1_BPP) - { - aLine.append( "/ImageMask true\n" ); - sal_Int32 nBlackIndex = pAccess->GetBestPaletteIndex( BitmapColor( COL_BLACK ) ); - SAL_WARN_IF( nBlackIndex != 0 && nBlackIndex != 1, "vcl.pdfwriter", "wrong black index" ); - if( nBlackIndex ) - aLine.append( "/Decode[ 1 0 ]\n" ); - else - aLine.append( "/Decode[ 0 1 ]\n" ); - } - else if (aBitmap.getPixelFormat() == vcl::PixelFormat::N8_BPP) - { - aLine.append( "/ColorSpace/DeviceGray\n" - "/Decode [ 1 0 ]\n" ); - } + aLine.append( "/ColorSpace/DeviceGray\n" + "/Decode [ 1 0 ]\n" ); } if( ! bMask && m_aContext.Version > PDFWriter::PDFVersion::PDF_1_2 && !m_bIsPDF_A1 ) @@ -9614,10 +9603,7 @@ const BitmapEmit& PDFWriterImpl::createBitmapEmit(const BitmapEx& i_rBitmap, con BitmapEx aBitmap( i_rBitmap ); auto ePixelFormat = aBitmap.GetBitmap().getPixelFormat(); if( m_aContext.ColorMode == PDFWriter::DrawGreyscale ) - { - if (ePixelFormat != vcl::PixelFormat::N1_BPP) - aBitmap.Convert(BmpConversion::N8BitGreys); - } + aBitmap.Convert(BmpConversion::N8BitGreys); BitmapID aID; aID.m_aPixelSize = aBitmap.GetSizePixel(); aID.m_nSize = vcl::pixelFormatBitCount(ePixelFormat); diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index ef82bdeee41f..d342c7a229a9 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -164,11 +164,7 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz return; if( m_aContext.ColorMode == PDFWriter::DrawGreyscale ) - { - auto ePixelFormat = aBitmapEx.GetBitmap().getPixelFormat(); - if (ePixelFormat != vcl::PixelFormat::N1_BPP) - aBitmapEx.Convert(BmpConversion::N8BitGreys); - } + aBitmapEx.Convert(BmpConversion::N8BitGreys); bool bUseJPGCompression = !i_rContext.m_bOnlyLosslessCompression; if ( bIsPng || ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) ) bUseJPGCompression = false; diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 6d014525aae0..95525639e493 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -110,7 +110,7 @@ void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, Bitmap aPaint( rBmp ), aMask( rMask ); BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE; - if (aMask.getPixelFormat() > vcl::PixelFormat::N1_BPP) + if (aMask.getPixelFormat() >= vcl::PixelFormat::N8_BPP) aMask.Convert( BmpConversion::N1BitThreshold ); // mirrored horizontally @@ -146,7 +146,7 @@ void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, // we always want to have a mask if( aMask.IsEmpty() ) { - aMask = Bitmap(aSrcRect.GetSize(), vcl::PixelFormat::N1_BPP); + aMask = Bitmap(aSrcRect.GetSize(), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); aMask.Erase( COL_BLACK ); } @@ -703,7 +703,7 @@ void Printer::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor, Bitmap aMask( rMask ); BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE; - if (aMask.getPixelFormat() > vcl::PixelFormat::N1_BPP) + if (aMask.getPixelFormat() >= vcl::PixelFormat::N8_BPP) aMask.Convert( BmpConversion::N1BitThreshold ); // mirrored horizontally diff --git a/vcl/source/helper/canvastools.cxx b/vcl/source/helper/canvastools.cxx index 595f12a959c8..e41417b8bdfe 100644 --- a/vcl/source/helper/canvastools.cxx +++ b/vcl/source/helper/canvastools.cxx @@ -267,12 +267,9 @@ namespace vcl::unotools // normalize bitcount auto ePixelFormat = - ( nDepth <= 1 ) ? vcl::PixelFormat::N1_BPP : ( nDepth <= 8 ) ? vcl::PixelFormat::N8_BPP : vcl::PixelFormat::N24_BPP; - auto eAlphaPixelFormat = - ( nAlphaDepth <= 1 ) ? vcl::PixelFormat::N1_BPP : - vcl::PixelFormat::N8_BPP; + auto eAlphaPixelFormat = vcl::PixelFormat::N8_BPP; ::Bitmap aBitmap( aPixelSize, ePixelFormat, diff --git a/vcl/source/rendercontext/drawmode.cxx b/vcl/source/rendercontext/drawmode.cxx index f33320d16216..995017c1f5b1 100644 --- a/vcl/source/rendercontext/drawmode.cxx +++ b/vcl/source/rendercontext/drawmode.cxx @@ -245,7 +245,8 @@ BitmapEx GetBitmapEx(BitmapEx const& rBitmapEx, DrawModeFlags nDrawMode) if (nDrawMode & (DrawModeFlags::BlackBitmap | DrawModeFlags::WhiteBitmap)) { - Bitmap aColorBmp(aBmpEx.GetSizePixel(), vcl::PixelFormat::N1_BPP); + Bitmap aColorBmp(aBmpEx.GetSizePixel(), vcl::PixelFormat::N8_BPP, + &Bitmap::GetGreyPalette(256)); sal_uInt8 cCmpVal; if (nDrawMode & DrawModeFlags::BlackBitmap) diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx index 804b50184af6..0f0d433e15f4 100644 --- a/vcl/unx/generic/gdi/salbmp.cxx +++ b/vcl/unx/generic/gdi/salbmp.cxx @@ -125,9 +125,6 @@ std::unique_ptr<BitmapBuffer> X11SalBitmap::ImplCreateDIB( switch(ePixelFormat) { - case vcl::PixelFormat::N1_BPP: - pDIB->mnFormat |= ScanlineFormat::N1BitMsbPal; - break; case vcl::PixelFormat::N8_BPP: pDIB->mnFormat |= ScanlineFormat::N8BitPal; break; |