summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-03-13 12:00:28 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-03-13 12:17:49 +0100
commit68bc6a5dd68006ab86e7ef26f9e5d241cb118879 (patch)
treedebd00d1a05228759974b2d09666dfcccb379ab3 /vcl
parenta73f24f47aea2dfa57459424f48b11b2b835e334 (diff)
add PixelFormat enum that replaces bit count in Bitmap/BitmapEx
Bit count for the image is a numeric value (sal_uInt16) but only a handful of values make sense - namely 1,4,8,24 and 32. This replaces the numeric value with an enum, which only accepts those values and checks the correct values are used at compile time. Change-Id: I0fc137c62bce3b0d021f05019a1648da628521bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112408 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/backendtest/outputdevice/bitmap.cxx10
-rw-r--r--vcl/qa/api/XGraphicTest.cxx2
-rw-r--r--vcl/qa/cppunit/BackendTest.cxx8
-rw-r--r--vcl/qa/cppunit/BitmapExTest.cxx6
-rw-r--r--vcl/qa/cppunit/BitmapFilterTest.cxx4
-rw-r--r--vcl/qa/cppunit/BitmapProcessorTest.cxx4
-rw-r--r--vcl/qa/cppunit/BitmapScaleTest.cxx6
-rw-r--r--vcl/qa/cppunit/BitmapTest.cxx41
-rw-r--r--vcl/qa/cppunit/GraphicDescriptorTest.cxx2
-rw-r--r--vcl/qa/cppunit/GraphicTest.cxx2
-rw-r--r--vcl/qa/cppunit/TypeSerializerTest.cxx2
-rw-r--r--vcl/qa/cppunit/canvasbitmaptest.cxx16
-rw-r--r--vcl/qa/cppunit/graphicfilter/filters-test.cxx4
-rw-r--r--vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx2
-rw-r--r--vcl/qa/cppunit/outdev.cxx4
-rw-r--r--vcl/qa/cppunit/skia/skia.cxx12
-rw-r--r--vcl/qa/cppunit/svm/svmtest.cxx28
-rw-r--r--vcl/source/bitmap/BitmapColorQuantizationFilter.cxx8
-rw-r--r--vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapDisabledImageFilter.cxx11
-rw-r--r--vcl/source/bitmap/BitmapDuoToneFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapEmbossGreyFilter.cxx3
-rw-r--r--vcl/source/bitmap/BitmapEx.cxx20
-rw-r--r--vcl/source/bitmap/BitmapFastScaleFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx4
-rw-r--r--vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx4
-rw-r--r--vcl/source/bitmap/BitmapLightenFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapMedianFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapMonochromeFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapMosaicFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx4
-rw-r--r--vcl/source/bitmap/BitmapScaleSuperFilter.cxx12
-rw-r--r--vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapSepiaFilter.cxx2
-rw-r--r--vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx10
-rw-r--r--vcl/source/bitmap/BitmapSobelGreyFilter.cxx3
-rw-r--r--vcl/source/bitmap/BitmapTools.cxx29
-rw-r--r--vcl/source/bitmap/alpha.cxx4
-rw-r--r--vcl/source/bitmap/bitmap.cxx76
-rw-r--r--vcl/source/bitmap/bitmappaint.cxx9
-rw-r--r--vcl/source/bitmap/dibtools.cxx48
-rw-r--r--vcl/source/filter/igif/gifread.cxx4
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx2
-rw-r--r--vcl/source/filter/itiff/itiff.cxx2
-rw-r--r--vcl/source/filter/ixbm/xbmread.cxx4
-rw-r--r--vcl/source/filter/ixpm/xpmread.cxx14
-rw-r--r--vcl/source/filter/jpeg/JpegReader.cxx6
-rw-r--r--vcl/source/filter/png/PngImageReader.cxx9
-rw-r--r--vcl/source/gdi/gdimtf.cxx2
-rw-r--r--vcl/source/gdi/print.cxx2
-rw-r--r--vcl/source/graphic/GraphicObject2.cxx2
-rw-r--r--vcl/source/helper/canvastools.cxx21
-rw-r--r--vcl/source/opengl/OpenGLHelper.cxx4
-rw-r--r--vcl/source/outdev/bitmap.cxx6
-rw-r--r--vcl/source/pdf/PDFiumLibrary.cxx2
-rw-r--r--vcl/workben/svptest.cxx2
-rw-r--r--vcl/workben/vcldemo.cxx6
57 files changed, 278 insertions, 226 deletions
diff --git a/vcl/backendtest/outputdevice/bitmap.cxx b/vcl/backendtest/outputdevice/bitmap.cxx
index 50060b88b7ed..2c7d7569cde6 100644
--- a/vcl/backendtest/outputdevice/bitmap.cxx
+++ b/vcl/backendtest/outputdevice/bitmap.cxx
@@ -18,7 +18,7 @@ namespace vcl::test {
Bitmap OutputDeviceTestBitmap::setupDrawTransformedBitmap()
{
Size aBitmapSize(9, 9);
- Bitmap aBitmap(aBitmapSize, 24);
+ Bitmap aBitmap(aBitmapSize, vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess aWriteAccess(aBitmap);
aWriteAccess->Erase(constFillColor);
@@ -43,7 +43,7 @@ Bitmap OutputDeviceTestBitmap::setupDrawTransformedBitmap()
Bitmap OutputDeviceTestBitmap::setupDrawBitmap()
{
Size aBitmapSize(9, 9);
- Bitmap aBitmap(aBitmapSize, 24);
+ Bitmap aBitmap(aBitmapSize, vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess aWriteAccess(aBitmap);
aWriteAccess->Erase(constFillColor);
@@ -65,7 +65,7 @@ Bitmap OutputDeviceTestBitmap::setupDrawBitmap()
Bitmap OutputDeviceTestBitmap::setupDrawBitmapExWithAlpha()
{
Size aBitmapSize(9, 9);
- Bitmap aBitmap(aBitmapSize, 24);
+ Bitmap aBitmap(aBitmapSize, vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess aWriteAccess(aBitmap);
aWriteAccess->Erase(COL_WHITE);
@@ -95,7 +95,7 @@ Bitmap OutputDeviceTestBitmap::setupDrawBitmapExWithAlpha()
Bitmap OutputDeviceTestBitmap::setupDrawMask()
{
Size aBitmapSize(9, 9);
- Bitmap aBitmap(aBitmapSize, 24);
+ Bitmap aBitmap(aBitmapSize, vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess aWriteAccess(aBitmap);
aWriteAccess->Erase(COL_WHITE);
@@ -114,7 +114,7 @@ Bitmap OutputDeviceTestBitmap::setupDrawMask()
BitmapEx OutputDeviceTestBitmap::setupDrawBlend()
{
Size aBitmapSize(9, 9);
- Bitmap aBitmap(aBitmapSize, 24);
+ Bitmap aBitmap(aBitmapSize, vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess aWriteAccess(aBitmap);
aWriteAccess->Erase(COL_WHITE);
diff --git a/vcl/qa/api/XGraphicTest.cxx b/vcl/qa/api/XGraphicTest.cxx
index 2dfe4f132346..afe50155a927 100644
--- a/vcl/qa/api/XGraphicTest.cxx
+++ b/vcl/qa/api/XGraphicTest.cxx
@@ -54,7 +54,7 @@ public:
BitmapEx createBitmap()
{
- Bitmap aBitmap(Size(100, 50), 24);
+ Bitmap aBitmap(Size(100, 50), vcl::PixelFormat::N24_BPP);
aBitmap.Erase(COL_LIGHTRED);
return BitmapEx(aBitmap);
diff --git a/vcl/qa/cppunit/BackendTest.cxx b/vcl/qa/cppunit/BackendTest.cxx
index 5e792506b665..2f05ac47aea8 100644
--- a/vcl/qa/cppunit/BackendTest.cxx
+++ b/vcl/qa/cppunit/BackendTest.cxx
@@ -473,7 +473,7 @@ public:
device->SetOutputSizePixel(Size(16, 16));
device->SetBackground(Wallpaper(COL_WHITE));
device->Erase();
- Bitmap aBitmap(Size(16, 16), 24);
+ Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP);
{
// Fill the top left quarter with black.
BitmapScopedWriteAccess pWriteAccess(aBitmap);
@@ -719,7 +719,7 @@ public:
device->SetOutputSizePixel(Size(10, 10));
device->SetBackground(Wallpaper(COL_WHITE));
device->Erase();
- Bitmap bitmap(Size(5, 5), 24);
+ Bitmap bitmap(Size(5, 5), vcl::PixelFormat::N24_BPP);
bitmap.Erase(COL_BLUE);
// No alpha, this will actually call SalGraphics::DrawBitmap(), but still check
// the alpha of the device is handled correctly.
@@ -776,7 +776,7 @@ public:
alphaDevice->SetOutputSizePixel(Size(20, 20));
alphaDevice->SetBackground(Wallpaper(COL_BLACK));
alphaDevice->Erase();
- Bitmap bitmap(Size(4, 4), 24);
+ Bitmap bitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);
AlphaMask alpha(Size(4, 4));
bitmap.Erase(COL_LIGHTBLUE);
{
@@ -867,7 +867,7 @@ public:
device->SetOutputSizePixel(Size(10, 10));
device->SetBackground(Wallpaper(COL_WHITE));
device->Erase();
- Bitmap bitmap(Size(10, 10), 24);
+ Bitmap bitmap(Size(10, 10), vcl::PixelFormat::N24_BPP);
bitmap.Erase(COL_BLUE);
basegfx::B2DHomMatrix matrix;
matrix.scale(bitmap.GetSizePixel().Width(),
diff --git a/vcl/qa/cppunit/BitmapExTest.cxx b/vcl/qa/cppunit/BitmapExTest.cxx
index 5e0fe1dddfc6..6f235237c2f3 100644
--- a/vcl/qa/cppunit/BitmapExTest.cxx
+++ b/vcl/qa/cppunit/BitmapExTest.cxx
@@ -34,7 +34,7 @@ class BitmapExTest : public CppUnit::TestFixture
void BitmapExTest::testGetPixelColor24_8()
{
- Bitmap aBitmap(Size(3, 3), 24);
+ Bitmap aBitmap(Size(3, 3), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pWriteAccess(aBitmap);
pWriteAccess->Erase(Color(ColorTransparency, 0x00, 0x00, 0xFF, 0x00));
@@ -59,7 +59,7 @@ void BitmapExTest::testGetPixelColor32()
if (!pBackendCapabilities->mbSupportsBitmap32)
return;
- Bitmap aBitmap(Size(3, 3), 32);
+ Bitmap aBitmap(Size(3, 3), vcl::PixelFormat::N32_BPP);
{
BitmapScopedWriteAccess pWriteAccess(aBitmap);
pWriteAccess->Erase(Color(ColorTransparency, 0xAA, 0x00, 0xFF, 0x00));
@@ -73,7 +73,7 @@ void BitmapExTest::testGetPixelColor32()
void BitmapExTest::testTransformBitmapEx()
{
- Bitmap aBitmap(Size(16, 16), 24);
+ Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pWriteAccess(aBitmap);
pWriteAccess->Erase(COL_WHITE);
diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx b/vcl/qa/cppunit/BitmapFilterTest.cxx
index 09831169e656..4bf651855937 100644
--- a/vcl/qa/cppunit/BitmapFilterTest.cxx
+++ b/vcl/qa/cppunit/BitmapFilterTest.cxx
@@ -77,7 +77,7 @@ void BitmapFilterTest::testBlurCorrectness()
{
// Setup test bitmap
Size aSize(41, 31);
- Bitmap aBitmap24Bit(aSize, 24);
+ Bitmap aBitmap24Bit(aSize, vcl::PixelFormat::N24_BPP);
ScanlineFormat scanlineFormat = ScanlineFormat::NONE;
sal_uInt16 nBPP = aBitmap24Bit.GetBitCount();
@@ -174,7 +174,7 @@ void BitmapFilterTest::testPerformance()
Size aSize(4000, 3000); // A rather common picture size
// Prepare bitmap
- Bitmap aBigBitmap(aSize, 24);
+ Bitmap aBigBitmap(aSize, vcl::PixelFormat::N24_BPP);
{
tools::Long aMargin = 500;
BitmapScopedWriteAccess aWriteAccess(aBigBitmap);
diff --git a/vcl/qa/cppunit/BitmapProcessorTest.cxx b/vcl/qa/cppunit/BitmapProcessorTest.cxx
index 07e49b47ca1b..b855aa146ed8 100644
--- a/vcl/qa/cppunit/BitmapProcessorTest.cxx
+++ b/vcl/qa/cppunit/BitmapProcessorTest.cxx
@@ -32,7 +32,7 @@ class BitmapProcessorTest : public CppUnit::TestFixture
void BitmapProcessorTest::testDisabledImage()
{
{
- Bitmap aBitmap(Size(3, 3), 24);
+ Bitmap aBitmap(Size(3, 3), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pWriteAccess(aBitmap);
pWriteAccess->Erase(Color(ColorTransparency, 0x00, 0x00, 0xFF, 0x00));
@@ -49,7 +49,7 @@ void BitmapProcessorTest::testDisabledImage()
}
{
- Bitmap aBitmap(Size(3, 3), 24);
+ Bitmap aBitmap(Size(3, 3), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pWriteAccess(aBitmap);
pWriteAccess->Erase(Color(ColorTransparency, 0x00, 0x00, 0xFF, 0x00));
diff --git a/vcl/qa/cppunit/BitmapScaleTest.cxx b/vcl/qa/cppunit/BitmapScaleTest.cxx
index 09ec8f9a3728..c6da34c6d2c6 100644
--- a/vcl/qa/cppunit/BitmapScaleTest.cxx
+++ b/vcl/qa/cppunit/BitmapScaleTest.cxx
@@ -121,7 +121,7 @@ void BitmapScaleTest::testScale()
+ scaleSize.destSize.toString() + "), method "
+ OString::number(static_cast<int>(scaleMethod));
fprintf(stderr, "%s\n", testStr.getStr());
- Bitmap bitmap(scaleSize.srcSize, 24);
+ Bitmap bitmap(scaleSize.srcSize, vcl::PixelFormat::N24_BPP);
{
// Fill each quarter of the source bitmap with a different color,
// and center with yet another color.
@@ -202,7 +202,7 @@ void BitmapScaleTest::testScale2()
{
const bool bExportBitmap(false);
- Bitmap aBitmap24Bit(Size(4096, 4096), 24);
+ Bitmap aBitmap24Bit(Size(4096, 4096), vcl::PixelFormat::N24_BPP);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(24), aBitmap24Bit.GetBitCount());
Color aBitmapColor = COL_YELLOW;
{
@@ -273,7 +273,7 @@ void BitmapScaleTest::testScaleSymmetry()
{
const bool bExportBitmap(false);
- Bitmap aBitmap24Bit(Size(10, 10), 24);
+ Bitmap aBitmap24Bit(Size(10, 10), vcl::PixelFormat::N24_BPP);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(24), aBitmap24Bit.GetBitCount());
{
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx
index e6c95d27b954..4a7cc5cc0477 100644
--- a/vcl/qa/cppunit/BitmapTest.cxx
+++ b/vcl/qa/cppunit/BitmapTest.cxx
@@ -99,7 +99,7 @@ void BitmapTest::testCreation()
}
{
- Bitmap aBmp(Size(10, 10), 1);
+ 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());
@@ -113,7 +113,7 @@ void BitmapTest::testCreation()
}
{
- Bitmap aBmp(Size(10, 10), 4);
+ Bitmap aBmp(Size(10, 10), vcl::PixelFormat::N4_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());
@@ -127,7 +127,7 @@ void BitmapTest::testCreation()
}
{
- Bitmap aBmp(Size(10, 10), 8);
+ 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());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong height", static_cast<tools::Long>(10), aSize.Height());
@@ -141,7 +141,7 @@ void BitmapTest::testCreation()
}
{
- Bitmap aBmp(Size(10, 10), 24);
+ Bitmap aBmp(Size(10, 10), vcl::PixelFormat::N24_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());
@@ -160,7 +160,7 @@ void BitmapTest::testCreation()
auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
if (pBackendCapabilities->mbSupportsBitmap32)
{
- Bitmap aBmp(Size(10, 10), 32);
+ Bitmap aBmp(Size(10, 10), vcl::PixelFormat::N32_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());
@@ -176,7 +176,7 @@ void BitmapTest::testCreation()
void BitmapTest::testEmpty()
{
- Bitmap aBitmap(Size(10, 10), 8);
+ Bitmap aBitmap(Size(10, 10), vcl::PixelFormat::N8_BPP);
aBitmap.Erase(COL_LIGHTGRAYBLUE);
CPPUNIT_ASSERT(!aBitmap.IsEmpty());
@@ -187,7 +187,7 @@ void BitmapTest::testEmpty()
Bitmap createTestBitmap()
{
- Bitmap aBmp(Size(4, 4), 24);
+ Bitmap aBmp(Size(4, 4), vcl::PixelFormat::N24_BPP);
BitmapWriteAccess aBmpAccess(aBmp);
// row 1
@@ -346,7 +346,7 @@ void BitmapTest::testN8Greyscale()
void BitmapTest::testConvert()
{
- Bitmap aBitmap(Size(10, 10), 8);
+ Bitmap aBitmap(Size(10, 10), vcl::PixelFormat::N8_BPP);
aBitmap.Erase(COL_LIGHTGRAYBLUE);
@@ -434,7 +434,7 @@ void BitmapTest::testCRC()
{
CRCHash aCRCs;
- Bitmap aBitmap(Size(1023, 759), 24, nullptr);
+ Bitmap aBitmap(Size(1023, 759), vcl::PixelFormat::N24_BPP);
aBitmap.Erase(COL_BLACK);
checkAndInsert(aCRCs, aBitmap, "black bitmap");
aBitmap.Invert();
@@ -519,7 +519,7 @@ void BitmapTest::testCustom8BitPalette()
{
aCustomPalette[i] = BitmapColor(sal_uInt8(i), sal_uInt8(0xCC), sal_uInt8(0x22));
}
- Bitmap aBitmap(Size(3, 2), 8, &aCustomPalette);
+ Bitmap aBitmap(Size(3, 2), vcl::PixelFormat::N8_BPP, &aCustomPalette);
{
BitmapScopedWriteAccess pAccess(aBitmap);
@@ -556,7 +556,7 @@ void BitmapTest::testCustom8BitPalette()
void BitmapTest::testErase()
{
- Bitmap aBitmap(Size(3, 3), 24);
+ Bitmap aBitmap(Size(3, 3), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pWriteAccess(aBitmap);
pWriteAccess->Erase(Color(0x11, 0x22, 0x33));
@@ -576,7 +576,7 @@ void BitmapTest::testBitmap32()
if (!pBackendCapabilities->mbSupportsBitmap32)
return;
- Bitmap aBitmap(Size(3, 3), 32);
+ Bitmap aBitmap(Size(3, 3), vcl::PixelFormat::N32_BPP);
{
BitmapScopedWriteAccess pWriteAccess(aBitmap);
pWriteAccess->Erase(Color(ColorTransparency, 0xFF, 0x11, 0x22, 0x33));
@@ -599,7 +599,7 @@ void BitmapTest::testBitmap32()
void BitmapTest::testOctree()
{
Size aSize(1000, 100);
- Bitmap aBitmap(aSize, 24);
+ Bitmap aBitmap(aSize, vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pWriteAccess(aBitmap);
for (tools::Long y = 0; y < aSize.Height(); ++y)
@@ -656,37 +656,40 @@ void BitmapTest::testDitherSize()
{
// no need to do anything for a 1x1 pixel bitmap
{
- Bitmap aBitmap(Size(1, 1), 24);
+ Bitmap aBitmap(Size(1, 1), vcl::PixelFormat::N24_BPP);
CPPUNIT_ASSERT(aBitmap.Dither());
}
// cannot dither a bitmap with a width of 2 or 3 pixels
{
- Bitmap aBitmap(Size(2, 4), 24);
+ Bitmap aBitmap(Size(2, 4), vcl::PixelFormat::N24_BPP);
CPPUNIT_ASSERT(!aBitmap.Dither());
}
{
- Bitmap aBitmap(Size(3, 4), 24);
+ Bitmap aBitmap(Size(3, 4), vcl::PixelFormat::N24_BPP);
CPPUNIT_ASSERT(!aBitmap.Dither());
}
// cannot dither a bitmap with a height of 2 pixels
{
- Bitmap aBitmap(Size(4, 2), 24);
+ Bitmap aBitmap(Size(4, 2), vcl::PixelFormat::N24_BPP);
CPPUNIT_ASSERT(!aBitmap.Dither());
}
// only dither bitmaps with a width > 3 pixels and height > 2 pixels
{
- Bitmap aBitmap(Size(4, 3), 24);
+ Bitmap aBitmap(Size(4, 3), vcl::PixelFormat::N24_BPP);
CPPUNIT_ASSERT(aBitmap.Dither());
}
}
void BitmapTest::testMirror()
{
- for (int bpp : { 4, 8, 24, 32 })
+ vcl::PixelFormat bppArray[] = { vcl::PixelFormat::N4_BPP, vcl::PixelFormat::N8_BPP,
+ vcl::PixelFormat::N24_BPP, vcl::PixelFormat::N32_BPP };
+
+ for (vcl::PixelFormat bpp : bppArray)
{
Bitmap bitmap(Size(11, 11), bpp);
{
diff --git a/vcl/qa/cppunit/GraphicDescriptorTest.cxx b/vcl/qa/cppunit/GraphicDescriptorTest.cxx
index 32466a4efcd7..652393ae9b63 100644
--- a/vcl/qa/cppunit/GraphicDescriptorTest.cxx
+++ b/vcl/qa/cppunit/GraphicDescriptorTest.cxx
@@ -46,7 +46,7 @@ class GraphicDescriptorTest : public test::BootstrapFixtureBase
BitmapEx createBitmap()
{
- Bitmap aBitmap(Size(100, 100), 24);
+ Bitmap aBitmap(Size(100, 100), vcl::PixelFormat::N24_BPP);
aBitmap.Erase(COL_LIGHTRED);
return BitmapEx(aBitmap);
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 55858e85ca13..a64ea67cdb78 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -126,7 +126,7 @@ GraphicTest::~GraphicTest()
BitmapEx createBitmap(bool alpha = false)
{
- Bitmap aBitmap(Size(120, 100), 24);
+ Bitmap aBitmap(Size(120, 100), vcl::PixelFormat::N24_BPP);
aBitmap.Erase(COL_LIGHTRED);
aBitmap.SetPrefSize(Size(6000, 5000));
diff --git a/vcl/qa/cppunit/TypeSerializerTest.cxx b/vcl/qa/cppunit/TypeSerializerTest.cxx
index e400a948f04a..f8de4e9ce3a2 100644
--- a/vcl/qa/cppunit/TypeSerializerTest.cxx
+++ b/vcl/qa/cppunit/TypeSerializerTest.cxx
@@ -189,7 +189,7 @@ void TypeSerializerTest::testGraphic_Vector()
void TypeSerializerTest::testGraphic_Bitmap_NoGfxLink()
{
- Bitmap aBitmap(Size(10, 10), 24);
+ Bitmap aBitmap(Size(10, 10), vcl::PixelFormat::N24_BPP);
aBitmap.Erase(COL_LIGHTGRAYBLUE);
BitmapEx aBitmapEx(aBitmap);
Graphic aGraphic(aBitmapEx);
diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx
index a26296a7b5e8..a741814adb41 100644
--- a/vcl/qa/cppunit/canvasbitmaptest.cxx
+++ b/vcl/qa/cppunit/canvasbitmaptest.cxx
@@ -633,14 +633,20 @@ public:
void CanvasBitmapTest::runTest()
{
- static const sal_Int8 lcl_depths[]={1,4,8,24};
+ static vcl::PixelFormat ePixelFormatArray[] =
+ {
+ vcl::PixelFormat::N1_BPP,
+ vcl::PixelFormat::N4_BPP,
+ vcl::PixelFormat::N8_BPP,
+ vcl::PixelFormat::N24_BPP
+ };
// Testing VclCanvasBitmap wrapper
- for( size_t i=0; i<SAL_N_ELEMENTS(lcl_depths); ++i )
+ for (auto const pixelFormat : ePixelFormatArray)
{
- const sal_Int8 nDepth( lcl_depths[i] );
- Bitmap aBitmap(Size(200,200),nDepth);
+ const sal_uInt16 nDepth = sal_uInt16(pixelFormat);
+ Bitmap aBitmap(Size(200,200), pixelFormat);
aBitmap.Erase(COL_WHITE);
{
BitmapScopedWriteAccess pAcc(aBitmap);
@@ -670,7 +676,7 @@ void CanvasBitmapTest::runTest()
checkCanvasBitmap( xBmp, "single bitmap", nDepth );
- Bitmap aMask(Size(200,200),1);
+ Bitmap aMask(Size(200,200), vcl::PixelFormat::N1_BPP);
aMask.Erase(COL_WHITE);
{
BitmapScopedWriteAccess pAcc(aMask);
diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx
index aee1dda1407e..ad5c1be8e8a4 100644
--- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx
@@ -92,7 +92,7 @@ void VclFiltersTest::testScaling()
{
for (BmpScaleFlag i = BmpScaleFlag::Default; i <= BmpScaleFlag::BiLinear; i = static_cast<BmpScaleFlag>(static_cast<int>(i) + 1))
{
- Bitmap aBitmap( Size( 413, 409 ), 24 );
+ Bitmap aBitmap(Size(413, 409), vcl::PixelFormat::N24_BPP);
BitmapEx aBitmapEx( aBitmap );
fprintf( stderr, "scale with type %d\n", int( i ) );
@@ -105,7 +105,7 @@ void VclFiltersTest::testScaling()
void VclFiltersTest::checkExportImport(std::u16string_view aFilterShortName)
{
- Bitmap aBitmap( Size( 100, 100 ), 24 );
+ Bitmap aBitmap(Size(100, 100), vcl::PixelFormat::N24_BPP);
aBitmap.Erase(COL_WHITE);
SvMemoryStream aStream;
diff --git a/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx
index 165d92562bff..4a06b2ed424c 100644
--- a/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx
@@ -126,7 +126,7 @@ void TiffFilterTest::testTdf138818()
void TiffFilterTest::testRoundtrip()
{
- Bitmap aBitmap(Size(2, 2), 24);
+ Bitmap aBitmap(Size(2, 2), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap);
pAccess->SetPixel(0, 0, COL_WHITE);
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 7bd1b0b53bd4..6385ec384e60 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -156,7 +156,7 @@ void VclOutdevTest::testDrawTransformedBitmapEx()
// Create a virtual device, and connect a metafile to it.
// Also create a 16x16 bitmap.
ScopedVclPtrInstance<VirtualDevice> pVDev;
- Bitmap aBitmap(Size(16, 16), 24);
+ Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP);
{
// Fill the top left quarter with black.
BitmapScopedWriteAccess pWriteAccess(aBitmap);
@@ -220,7 +220,7 @@ void VclOutdevTest::testDrawTransformedBitmapExFlip()
// Create a virtual device, and connect a metafile to it.
// Also create a 16x16 bitmap.
ScopedVclPtrInstance<VirtualDevice> pVDev;
- Bitmap aBitmap(Size(16, 16), 24);
+ Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP);
{
// Fill the top left quarter with black.
BitmapScopedWriteAccess pWriteAccess(aBitmap);
diff --git a/vcl/qa/cppunit/skia/skia.cxx b/vcl/qa/cppunit/skia/skia.cxx
index 3160920405f9..8f288d813404 100644
--- a/vcl/qa/cppunit/skia/skia.cxx
+++ b/vcl/qa/cppunit/skia/skia.cxx
@@ -73,7 +73,7 @@ void SkiaTest::testBitmapErase()
{
if (!SkiaHelper::isVCLSkiaEnabled())
return;
- Bitmap bitmap(Size(10, 10), 24);
+ Bitmap bitmap(Size(10, 10), vcl::PixelFormat::N24_BPP);
SkiaSalBitmap* skiaBitmap = dynamic_cast<SkiaSalBitmap*>(bitmap.ImplGetSalBitmap().get());
CPPUNIT_ASSERT(skiaBitmap);
// Uninitialized bitmap.
@@ -106,7 +106,7 @@ void SkiaTest::testDrawShaders()
device->SetOutputSizePixel(Size(20, 20));
device->SetBackground(Wallpaper(COL_WHITE));
device->Erase();
- Bitmap bitmap(Size(10, 10), 24);
+ Bitmap bitmap(Size(10, 10), vcl::PixelFormat::N24_BPP);
bitmap.Erase(COL_RED);
SkiaSalBitmap* skiaBitmap = dynamic_cast<SkiaSalBitmap*>(bitmap.ImplGetSalBitmap().get());
CPPUNIT_ASSERT(skiaBitmap->PreferSkShader());
@@ -149,7 +149,7 @@ void SkiaTest::testDrawShaders()
deviceLarge->SetOutputSizePixel(Size(200, 200));
deviceLarge->SetBackground(Wallpaper(COL_WHITE));
deviceLarge->Erase();
- Bitmap bitmapLarge(Size(100, 100), 24);
+ Bitmap bitmapLarge(Size(100, 100), vcl::PixelFormat::N24_BPP);
bitmapLarge.Erase(COL_RED);
SkiaSalBitmap* skiaBitmapLarge
= dynamic_cast<SkiaSalBitmap*>(bitmapLarge.ImplGetSalBitmap().get());
@@ -184,7 +184,7 @@ void SkiaTest::testInterpretAs8Bit()
{
if (!SkiaHelper::isVCLSkiaEnabled())
return;
- Bitmap bitmap(Size(10, 10), 24);
+ Bitmap bitmap(Size(10, 10), vcl::PixelFormat::N24_BPP);
// Test with erase color.
bitmap.Erase(Color(33, 33, 33));
SkiaSalBitmap* skiaBitmap = dynamic_cast<SkiaSalBitmap*>(bitmap.ImplGetSalBitmap().get());
@@ -197,7 +197,7 @@ void SkiaTest::testInterpretAs8Bit()
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(33), BitmapReadAccess(bitmap).GetPixelIndex(0, 0));
// Test with image.
- bitmap = Bitmap(Size(10, 10), 24);
+ bitmap = Bitmap(Size(10, 10), vcl::PixelFormat::N24_BPP);
bitmap.Erase(Color(34, 34, 34));
BitmapReadAccess(bitmap).GetColor(0, 0); // Create pixel data, reset erase color.
skiaBitmap = dynamic_cast<SkiaSalBitmap*>(bitmap.ImplGetSalBitmap().get());
@@ -217,7 +217,7 @@ void SkiaTest::testAlphaBlendWith()
if (!SkiaHelper::isVCLSkiaEnabled())
return;
AlphaMask alpha(Size(10, 10));
- Bitmap bitmap(Size(10, 10), 24);
+ Bitmap bitmap(Size(10, 10), vcl::PixelFormat::N24_BPP);
// Test with erase colors set.
alpha.Erase(64);
SkiaSalBitmap* skiaAlpha = dynamic_cast<SkiaSalBitmap*>(alpha.ImplGetSalBitmap().get());
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index f8a4c0a96734..beb70c614791 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -939,17 +939,17 @@ void SvmTest::testBitmaps()
ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile);
- Bitmap aBitmap1(Size(4,4), 24);
+ Bitmap aBitmap1(Size(4,4), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap1);
pAccess->Erase(COL_RED);
}
- Bitmap aBitmap2(Size(4,4), 24);
+ Bitmap aBitmap2(Size(4,4), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap2);
pAccess->Erase(COL_GREEN);
}
- Bitmap aBitmap3(Size(4,4), 24);
+ Bitmap aBitmap3(Size(4,4), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap3);
pAccess->Erase(COL_BLUE);
@@ -1030,7 +1030,7 @@ void SvmTest::testBitmapExs()
// DrawBitmapEx
{
- Bitmap aBitmap(Size(4,4), 24);
+ Bitmap aBitmap(Size(4,4), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap);
pAccess->Erase(COL_YELLOW);
@@ -1041,7 +1041,7 @@ void SvmTest::testBitmapExs()
// DrawBitmapEx - Scale
{
- Bitmap aBitmap(Size(4,4), 24);
+ Bitmap aBitmap(Size(4,4), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap);
pAccess->Erase(COL_GREEN);
@@ -1051,7 +1051,7 @@ void SvmTest::testBitmapExs()
// DrawBitmapEx - Scale - Part
{
- Bitmap aBitmap(Size(4,4), 24);
+ Bitmap aBitmap(Size(4,4), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap);
pAccess->Erase(COL_BLUE);
@@ -1061,7 +1061,7 @@ void SvmTest::testBitmapExs()
// DrawBitmapEx - 50% transparent
{
- Bitmap aBitmap(Size(4, 4), 24);
+ Bitmap aBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);
AlphaMask aAlpha(Size(4, 4));
{
BitmapScopedWriteAccess pAccess(aBitmap);
@@ -1075,7 +1075,7 @@ void SvmTest::testBitmapExs()
// DrawBitmapEx - 1-bit
{
- Bitmap aBitmap(Size(2, 2), 24);
+ Bitmap aBitmap(Size(2, 2), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap);
pAccess->Erase(COL_MAGENTA);
@@ -1086,7 +1086,7 @@ void SvmTest::testBitmapExs()
// DrawBitmapEx - 4-bit
{
- Bitmap aBitmap(Size(2, 2), 24);
+ Bitmap aBitmap(Size(2, 2), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap);
pAccess->Erase(COL_MAGENTA);
@@ -1097,7 +1097,7 @@ void SvmTest::testBitmapExs()
// DrawBitmapEx - 8-bit Color
{
- Bitmap aBitmap(Size(2, 2), 24);
+ Bitmap aBitmap(Size(2, 2), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap);
pAccess->Erase(COL_MAGENTA);
@@ -1108,7 +1108,7 @@ void SvmTest::testBitmapExs()
// DrawBitmapEx - 8-bit Grey
{
- Bitmap aBitmap(Size(2, 2), 24);
+ Bitmap aBitmap(Size(2, 2), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap);
pAccess->Erase(COL_MAGENTA);
@@ -1157,17 +1157,17 @@ void SvmTest::testMasks()
ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile);
- Bitmap aBitmap1(Size(4,4), 24);
+ Bitmap aBitmap1(Size(4,4), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap1);
pAccess->Erase(COL_RED);
}
- Bitmap aBitmap2(Size(4,4), 24);
+ Bitmap aBitmap2(Size(4,4), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap2);
pAccess->Erase(COL_GREEN);
}
- Bitmap aBitmap3(Size(4,4), 24);
+ Bitmap aBitmap3(Size(4,4), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pAccess(aBitmap3);
pAccess->Erase(COL_BLUE);
diff --git a/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx
index 6cbf97a274ee..5bd5a3127911 100644
--- a/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx
+++ b/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx
@@ -32,14 +32,14 @@ BitmapEx BitmapColorQuantizationFilter::execute(BitmapEx const& aBitmapEx) const
else
{
Bitmap::ScopedReadAccess pRAcc(aBitmap);
- sal_uInt16 nBitCount;
+ vcl::PixelFormat ePixelFormat;
auto const cappedNewColorCount = std::min(mnNewColorCount, sal_uInt16(256));
if (cappedNewColorCount < 17)
- nBitCount = 4;
+ ePixelFormat = vcl::PixelFormat::N4_BPP;
else
- nBitCount = 8;
+ ePixelFormat = vcl::PixelFormat::N8_BPP;
if (pRAcc)
{
@@ -135,7 +135,7 @@ BitmapEx BitmapColorQuantizationFilter::execute(BitmapEx const& aBitmapEx) const
<< nRightShiftBits));
}
- Bitmap aNewBmp(aBitmap.GetSizePixel(), nBitCount, &aNewPal);
+ Bitmap aNewBmp(aBitmap.GetSizePixel(), ePixelFormat, &aNewPal);
BitmapScopedWriteAccess pWAcc(aNewBmp);
if (pWAcc)
diff --git a/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx b/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx
index 9d41b5039193..ce5715ea8530 100644
--- a/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx
+++ b/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx
@@ -29,7 +29,7 @@ BitmapEx BitmapConvolutionMatrixFilter::execute(BitmapEx const& rBitmapEx) const
if (pReadAcc)
{
- Bitmap aNewBmp(aBitmap.GetSizePixel(), 24);
+ Bitmap aNewBmp(aBitmap.GetSizePixel(), vcl::PixelFormat::N24_BPP);
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
diff --git a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
index 82b6c7f07d5e..e258d897ab1f 100644
--- a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
+++ b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
@@ -17,12 +17,13 @@ BitmapEx BitmapDisabledImageFilter::execute(BitmapEx const& rBitmapEx) const
// keep disable image at same depth as original where possible, otherwise
// use 8 bit
- sal_uInt16 nBitCount = rBitmapEx.GetBitCount();
- if (nBitCount < 8)
- nBitCount = 8;
+ auto ePixelFormat = rBitmapEx.getPixelFormat();
+ if (sal_uInt16(ePixelFormat) < 8)
+ ePixelFormat = vcl::PixelFormat::N8_BPP;
- const BitmapPalette* pPal = nBitCount == 8 ? &Bitmap::GetGreyPalette(256) : nullptr;
- Bitmap aGrey(aSize, nBitCount, pPal);
+ const BitmapPalette* pPal
+ = vcl::isPalettePixelFormat(ePixelFormat) ? &Bitmap::GetGreyPalette(256) : nullptr;
+ Bitmap aGrey(aSize, ePixelFormat, pPal);
BitmapScopedWriteAccess pGrey(aGrey);
BitmapEx aReturnBitmap;
diff --git a/vcl/source/bitmap/BitmapDuoToneFilter.cxx b/vcl/source/bitmap/BitmapDuoToneFilter.cxx
index 040f753386fd..9afb82ee9237 100644
--- a/vcl/source/bitmap/BitmapDuoToneFilter.cxx
+++ b/vcl/source/bitmap/BitmapDuoToneFilter.cxx
@@ -29,7 +29,7 @@ BitmapEx BitmapDuoToneFilter::execute(BitmapEx const& rBitmapEx) const
const tools::Long nWidth = aBitmap.GetSizePixel().Width();
const tools::Long nHeight = aBitmap.GetSizePixel().Height();
- Bitmap aResultBitmap(aBitmap.GetSizePixel(), 24);
+ Bitmap aResultBitmap(aBitmap.GetSizePixel(), vcl::PixelFormat::N24_BPP);
Bitmap::ScopedReadAccess pReadAcc(aBitmap);
BitmapScopedWriteAccess pWriteAcc(aResultBitmap);
const BitmapColor aColorOne(static_cast<sal_uInt8>(mnColorOne >> 16),
diff --git a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
index d285bfb2b2a8..af8e5e9914ba 100644
--- a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
+++ b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
@@ -34,7 +34,8 @@ BitmapEx BitmapEmbossGreyFilter::execute(BitmapEx const& rBitmapEx) const
if (pReadAcc)
{
- Bitmap aNewBmp(aBitmap.GetSizePixel(), 8, &pReadAcc->GetPalette());
+ Bitmap aNewBmp(aBitmap.GetSizePixel(), vcl::PixelFormat::N8_BPP,
+ &pReadAcc->GetPalette());
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index db889e8c6a98..a2667cbb6534 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -62,7 +62,7 @@ BitmapEx::BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize )
if( rBitmapEx.IsEmpty() )
return;
- maBitmap = Bitmap( aSize, rBitmapEx.maBitmap.GetBitCount() );
+ maBitmap = Bitmap(aSize, rBitmapEx.maBitmap.getPixelFormat());
SetSizePixel(aSize);
if( rBitmapEx.IsAlpha() )
{
@@ -70,18 +70,18 @@ BitmapEx::BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize )
maMask = AlphaMask( aSize ).ImplGetBitmap();
}
else if( rBitmapEx.IsTransparent() )
- maMask = Bitmap( aSize, rBitmapEx.maMask.GetBitCount() );
+ maMask = Bitmap(aSize, rBitmapEx.maMask.getPixelFormat());
tools::Rectangle aDestRect( Point( 0, 0 ), aSize );
tools::Rectangle aSrcRect( aSrc, aSize );
CopyPixel( aDestRect, aSrcRect, &rBitmapEx );
}
-BitmapEx::BitmapEx( Size aSize, sal_uInt16 nBitCount )
+BitmapEx::BitmapEx(Size aSize, vcl::PixelFormat ePixelFormat)
: meTransparent(TransparentType::NONE)
, mbAlpha(false)
{
- maBitmap = Bitmap( aSize, nBitCount );
+ maBitmap = Bitmap(aSize, ePixelFormat);
SetSizePixel(aSize);
}
@@ -383,7 +383,7 @@ bool BitmapEx::Rotate( Degree10 nAngle10, const Color& rFillColor )
if( meTransparent == TransparentType::NONE )
{
- maMask = Bitmap(GetSizePixel(), 1);
+ maMask = Bitmap(GetSizePixel(), vcl::PixelFormat::N1_BPP);
maMask.Erase( COL_BLACK );
meTransparent = TransparentType::Bitmap;
}
@@ -516,7 +516,7 @@ bool BitmapEx::CopyPixel( const tools::Rectangle& rRectDst, const tools::Rectang
}
else
{
- maMask = Bitmap(GetSizePixel(), 1);
+ maMask = Bitmap(GetSizePixel(), vcl::PixelFormat::N1_BPP);
maMask.Erase(COL_BLACK);
meTransparent = TransparentType::Bitmap;
maMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maMask );
@@ -531,7 +531,7 @@ bool BitmapEx::CopyPixel( const tools::Rectangle& rRectDst, const tools::Rectang
}
else if (IsTransparent())
{
- Bitmap aMaskSrc(pBmpExSrc->GetSizePixel(), 1);
+ Bitmap aMaskSrc(pBmpExSrc->GetSizePixel(), vcl::PixelFormat::N1_BPP);
aMaskSrc.Erase( COL_BLACK );
maMask.CopyPixel( rRectDst, rRectSrc, &aMaskSrc );
@@ -779,7 +779,7 @@ namespace
const basegfx::B2DHomMatrix& rTransform,
bool bSmooth)
{
- Bitmap aDestination(rDestinationSize, 24);
+ Bitmap aDestination(rDestinationSize, vcl::PixelFormat::N24_BPP);
BitmapScopedWriteAccess xWrite(aDestination);
if(xWrite)
@@ -1006,7 +1006,7 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod
aNewPalette[0] = BitmapColor(Color(pReplace->getBColor()));
aChangedBitmap = Bitmap(
aChangedBitmap.GetSizePixel(),
- aChangedBitmap.GetBitCount(),
+ aChangedBitmap.getPixelFormat(),
&aNewPalette);
}
}
@@ -1185,7 +1185,7 @@ BitmapEx createBlendFrame(
if(nW > 1 && nH > 1)
{
sal_uInt8 aEraseTrans(0xff);
- Bitmap aContent(rSize, 24);
+ Bitmap aContent(rSize, vcl::PixelFormat::N24_BPP);
AlphaMask aAlpha(rSize, &aEraseTrans);
aContent.Erase(COL_BLACK);
diff --git a/vcl/source/bitmap/BitmapFastScaleFilter.cxx b/vcl/source/bitmap/BitmapFastScaleFilter.cxx
index 0bcbc27ab8c7..feeee6c79931 100644
--- a/vcl/source/bitmap/BitmapFastScaleFilter.cxx
+++ b/vcl/source/bitmap/BitmapFastScaleFilter.cxx
@@ -44,7 +44,7 @@ BitmapEx BitmapFastScaleFilter::execute(BitmapEx const& rBitmapEx) const
if (pReadAcc)
{
- Bitmap aNewBmp(Size(nNewWidth, nNewHeight), aBitmap.GetBitCount(),
+ Bitmap aNewBmp(Size(nNewWidth, nNewHeight), aBitmap.getPixelFormat(),
&pReadAcc->GetPalette());
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
diff --git a/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx b/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx
index bf39a22298ce..93c3399be493 100644
--- a/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx
+++ b/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx
@@ -36,7 +36,7 @@ BitmapEx BitmapGaussianSeparableBlurFilter::execute(BitmapEx const& rBitmapEx) c
Bitmap::ScopedReadAccess pReadAcc(aBitmap);
// switch coordinates as convolution pass transposes result
- Bitmap aNewBitmap(Size(nHeight, nWidth), 24);
+ Bitmap aNewBitmap(Size(nHeight, nWidth), vcl::PixelFormat::N24_BPP);
bool bResult = convolutionPass(aBitmap, aNewBitmap, pReadAcc.get(), aNumberOfContributions,
aWeights.data(), aPixels.data(), aCounts.data());
@@ -60,7 +60,7 @@ BitmapEx BitmapGaussianSeparableBlurFilter::execute(BitmapEx const& rBitmapEx) c
blurContributions(nHeight, aNumberOfContributions, aBlurVector, aWeights, aPixels, aCounts);
pReadAcc = Bitmap::ScopedReadAccess(aBitmap);
- aNewBitmap = Bitmap(Size(nWidth, nHeight), 24);
+ aNewBitmap = Bitmap(Size(nWidth, nHeight), vcl::PixelFormat::N24_BPP);
bResult = convolutionPass(aBitmap, aNewBitmap, pReadAcc.get(), aNumberOfContributions,
aWeights.data(), aPixels.data(), aCounts.data());
diff --git a/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx b/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx
index 06e16d460624..973e357fb2f5 100644
--- a/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx
+++ b/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx
@@ -42,7 +42,7 @@ BitmapEx BitmapInterpolateScaleFilter::execute(BitmapEx const& rBitmapEx) const
{
tools::Long nWidth = pReadAcc->Width();
tools::Long nHeight = pReadAcc->Height();
- Bitmap aNewBmp(Size(nNewWidth, nHeight), 24);
+ Bitmap aNewBmp(Size(nNewWidth, nHeight), vcl::PixelFormat::N24_BPP);
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
@@ -137,7 +137,7 @@ BitmapEx BitmapInterpolateScaleFilter::execute(BitmapEx const& rBitmapEx) const
bRet = false;
const Bitmap aOriginal(aBitmap);
aBitmap = aNewBmp;
- aNewBmp = Bitmap(Size(nNewWidth, nNewHeight), 24);
+ aNewBmp = Bitmap(Size(nNewWidth, nNewHeight), vcl::PixelFormat::N24_BPP);
pReadAcc = Bitmap::ScopedReadAccess(aBitmap);
pWriteAcc = BitmapScopedWriteAccess(aNewBmp);
diff --git a/vcl/source/bitmap/BitmapLightenFilter.cxx b/vcl/source/bitmap/BitmapLightenFilter.cxx
index 137f69234453..35b06566855f 100644
--- a/vcl/source/bitmap/BitmapLightenFilter.cxx
+++ b/vcl/source/bitmap/BitmapLightenFilter.cxx
@@ -18,7 +18,7 @@ BitmapEx BitmapLightenFilter::execute(BitmapEx const& rBitmapEx) const
const Size aSize(rBitmapEx.GetSizePixel());
Bitmap aBitmap(rBitmapEx.GetBitmap());
- Bitmap aDarkBitmap(aSize, 24);
+ Bitmap aDarkBitmap(aSize, vcl::PixelFormat::N24_BPP);
Bitmap::ScopedReadAccess pRead(aBitmap);
BitmapScopedWriteAccess pWrite(aDarkBitmap);
diff --git a/vcl/source/bitmap/BitmapMedianFilter.cxx b/vcl/source/bitmap/BitmapMedianFilter.cxx
index 9f2e2ce60d7d..2e0b6556005d 100644
--- a/vcl/source/bitmap/BitmapMedianFilter.cxx
+++ b/vcl/source/bitmap/BitmapMedianFilter.cxx
@@ -58,7 +58,7 @@ BitmapEx BitmapMedianFilter::execute(BitmapEx const& rBitmapEx) const
if (pReadAcc)
{
- Bitmap aNewBmp(aBitmap.GetSizePixel(), 24);
+ Bitmap aNewBmp(aBitmap.GetSizePixel(), vcl::PixelFormat::N24_BPP);
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
diff --git a/vcl/source/bitmap/BitmapMonochromeFilter.cxx b/vcl/source/bitmap/BitmapMonochromeFilter.cxx
index a460f58923ff..365e06a7a15c 100644
--- a/vcl/source/bitmap/BitmapMonochromeFilter.cxx
+++ b/vcl/source/bitmap/BitmapMonochromeFilter.cxx
@@ -22,7 +22,7 @@ BitmapEx BitmapMonochromeFilter::execute(BitmapEx const& aBitmapEx) const
if (pReadAcc)
{
- Bitmap aNewBmp(aBitmap.GetSizePixel(), 1);
+ Bitmap aNewBmp(aBitmap.GetSizePixel(), vcl::PixelFormat::N1_BPP);
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
diff --git a/vcl/source/bitmap/BitmapMosaicFilter.cxx b/vcl/source/bitmap/BitmapMosaicFilter.cxx
index 2f1e8ec8d704..d04321c0bcee 100644
--- a/vcl/source/bitmap/BitmapMosaicFilter.cxx
+++ b/vcl/source/bitmap/BitmapMosaicFilter.cxx
@@ -32,7 +32,7 @@ BitmapEx BitmapMosaicFilter::execute(BitmapEx const& rBitmapEx) const
}
else
{
- pNewBmp.reset(new Bitmap(aBitmap.GetSizePixel(), 24));
+ pNewBmp.reset(new Bitmap(aBitmap.GetSizePixel(), vcl::PixelFormat::N24_BPP));
pReadAcc = aBitmap.AcquireReadAccess();
pWriteAcc = pNewBmp->AcquireWriteAccess();
}
diff --git a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
index 21205d020360..b1115a1dfe56 100644
--- a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
+++ b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
@@ -108,7 +108,7 @@ bool ImplScaleConvolutionHor(Bitmap& rSource, Bitmap& rTarget, const double& rSc
const tools::Long nHeight(rSource.GetSizePixel().Height());
ImplCalculateContributions(nWidth, nNewWidth, aNumberOfContributions, aWeights, aPixels, aCounts, aKernel);
- rTarget = Bitmap(Size(nNewWidth, nHeight), 24);
+ rTarget = Bitmap(Size(nNewWidth, nHeight), vcl::PixelFormat::N24_BPP);
BitmapScopedWriteAccess pWriteAcc(rTarget);
bool bResult(pWriteAcc);
@@ -198,7 +198,7 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc
const tools::Long nWidth(rSource.GetSizePixel().Width());
ImplCalculateContributions(nHeight, nNewHeight, aNumberOfContributions, aWeights, aPixels, aCounts, aKernel);
- rTarget = Bitmap(Size(nWidth, nNewHeight), 24);
+ rTarget = Bitmap(Size(nWidth, nNewHeight), vcl::PixelFormat::N24_BPP);
BitmapScopedWriteAccess pWriteAcc(rTarget);
bool bResult(pWriteAcc);
diff --git a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
index a15ec0ab9fb8..e8cf70a98a16 100644
--- a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
+++ b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
@@ -882,11 +882,15 @@ BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap) const
{
Bitmap::ScopedReadAccess pReadAccess(aBitmap);
- sal_uInt16 nSourceBitcount = aBitmap.GetBitCount();
+ // If source format is less than 24BPP, use 24BPP
+ auto eSourcePixelFormat = aBitmap.getPixelFormat();
+ auto ePixelFormat = eSourcePixelFormat;
+ if (sal_uInt16(eSourcePixelFormat) < 24)
+ ePixelFormat = vcl::PixelFormat::N24_BPP;
- Bitmap aOutBmp(Size(nDstW, nDstH), std::max(nSourceBitcount, sal_uInt16(24)));
+ Bitmap aOutBmp(Size(nDstW, nDstH), ePixelFormat);
Size aOutSize = aOutBmp.GetSizePixel();
- sal_uInt16 nTargetBitcount = aOutBmp.GetBitCount();
+ auto eTargetPixelFormat = aOutBmp.getPixelFormat();
if (!aOutSize.Width() || !aOutSize.Height())
{
@@ -932,7 +936,7 @@ BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap) const
// the capabilities of the backend. If for some reason the destination
// is not the same bit-depth as the source, then we can't use
// a fast path, so we always need to process with a general scaler.
- else if (nSourceBitcount != nTargetBitcount)
+ else if (eSourcePixelFormat != eTargetPixelFormat)
{
pScaleRangeFn = bScaleUp ? scaleUpNonPaletteGeneral : scaleDownNonPaletteGeneral;
}
diff --git a/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx b/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx
index 002976816c17..c8aae120a48b 100644
--- a/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx
+++ b/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx
@@ -33,7 +33,7 @@ BitmapEx BitmapSeparableUnsharpenFilter::execute(BitmapEx const& rBitmapEx) cons
// Amount of unsharpening effect on image - currently set to a fixed value
double aAmount = 2.0;
- Bitmap aResultBitmap(Size(nWidth, nHeight), 24);
+ Bitmap aResultBitmap(Size(nWidth, nHeight), vcl::PixelFormat::N24_BPP);
Bitmap::ScopedReadAccess pReadAccBlur(aBlur);
Bitmap::ScopedReadAccess pReadAcc(aBitmap);
diff --git a/vcl/source/bitmap/BitmapSepiaFilter.cxx b/vcl/source/bitmap/BitmapSepiaFilter.cxx
index 7093c5048616..e7a56080a8cc 100644
--- a/vcl/source/bitmap/BitmapSepiaFilter.cxx
+++ b/vcl/source/bitmap/BitmapSepiaFilter.cxx
@@ -40,7 +40,7 @@ BitmapEx BitmapSepiaFilter::execute(BitmapEx const& rBitmapEx) const
rCol.SetBlue(cSepiaValue);
}
- Bitmap aNewBmp(aBitmap.GetSizePixel(), 8, &aSepiaPal);
+ Bitmap aNewBmp(aBitmap.GetSizePixel(), vcl::PixelFormat::N8_BPP, &aSepiaPal);
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
diff --git a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
index 8ff988ab3407..25df8ae3a46c 100644
--- a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
+++ b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
@@ -30,21 +30,21 @@ BitmapEx BitmapSimpleColorQuantizationFilter::execute(BitmapEx const& aBitmapEx)
Bitmap aNewBmp;
Bitmap::ScopedReadAccess pRAcc(aBitmap);
const sal_uInt16 nColorCount = std::min(mnNewColorCount, sal_uInt16(256));
- sal_uInt16 nBitCount = 0;
+ auto ePixelFormat = vcl::PixelFormat::INVALID;
if (nColorCount <= 2)
- nBitCount = 1;
+ ePixelFormat = vcl::PixelFormat::N1_BPP;
else if (nColorCount <= 16)
- nBitCount = 4;
+ ePixelFormat = vcl::PixelFormat::N4_BPP;
else
- nBitCount = 8;
+ ePixelFormat = vcl::PixelFormat::N8_BPP;
if (pRAcc)
{
Octree aOct(*pRAcc, nColorCount);
const BitmapPalette& rPal = aOct.GetPalette();
- aNewBmp = Bitmap(aBitmap.GetSizePixel(), nBitCount, &rPal);
+ aNewBmp = Bitmap(aBitmap.GetSizePixel(), ePixelFormat, &rPal);
BitmapScopedWriteAccess pWAcc(aNewBmp);
if (pWAcc)
diff --git a/vcl/source/bitmap/BitmapSobelGreyFilter.cxx b/vcl/source/bitmap/BitmapSobelGreyFilter.cxx
index f042f10bf51e..74e8c233d225 100644
--- a/vcl/source/bitmap/BitmapSobelGreyFilter.cxx
+++ b/vcl/source/bitmap/BitmapSobelGreyFilter.cxx
@@ -32,7 +32,8 @@ BitmapEx BitmapSobelGreyFilter::execute(BitmapEx const& rBitmapEx) const
if (pReadAcc)
{
- Bitmap aNewBmp(aBitmap.GetSizePixel(), 8, &pReadAcc->GetPalette());
+ Bitmap aNewBmp(aBitmap.GetSizePixel(), vcl::PixelFormat::N8_BPP,
+ &pReadAcc->GetPalette());
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index c81380adeeb0..89d97c953886 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -121,11 +121,14 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
@param nStride
The number of bytes in a scanline, must >= (width * nBitCount / 8)
*/
-BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount )
+BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, vcl::PixelFormat ePixelFormat)
{
+ auto nBitCount = sal_uInt16(ePixelFormat);
+
assert(nStride >= (nWidth * nBitCount / 8));
- assert( nBitCount == 1 || nBitCount == 24 || nBitCount == 32);
- Bitmap aBmp( Size( nWidth, nHeight ), nBitCount );
+ assert(nBitCount == 1 || nBitCount == 24 || nBitCount == 32);
+
+ Bitmap aBmp(Size(nWidth, nHeight), ePixelFormat);
BitmapScopedWriteAccess pWrite(aBmp);
assert(pWrite.get());
@@ -188,7 +191,17 @@ BitmapEx CreateFromData( RawBitmap&& rawBitmap )
{
auto nBitCount = rawBitmap.GetBitCount();
assert( nBitCount == 24 || nBitCount == 32);
- Bitmap aBmp( rawBitmap.maSize, nBitCount );
+
+ auto ePixelFormat = vcl::PixelFormat::INVALID;
+
+ if (nBitCount == 24)
+ ePixelFormat = vcl::PixelFormat::N24_BPP;
+ else if (nBitCount == 32)
+ ePixelFormat = vcl::PixelFormat::N32_BPP;
+
+ assert(ePixelFormat != vcl::PixelFormat::INVALID);
+
+ Bitmap aBmp(rawBitmap.maSize, ePixelFormat);
BitmapScopedWriteAccess pWrite(aBmp);
assert(pWrite.get());
@@ -255,7 +268,7 @@ BitmapEx* CreateFromCairoSurface(Size aSize, cairo_surface_t * pSurface)
cairo_set_operator( pCairo, CAIRO_OPERATOR_SOURCE );
cairo_paint( pCairo );
- ::Bitmap aRGB( aSize, 24 );
+ Bitmap aRGB(aSize, vcl::PixelFormat::N24_BPP);
::AlphaMask aMask( aSize );
BitmapScopedWriteAccess pRGBWrite(aRGB);
@@ -382,7 +395,7 @@ BitmapEx CanvasTransformBitmap( const BitmapEx& rBitmap,
if( aDestBmpSize.IsEmpty() )
return BitmapEx();
- Bitmap aDstBitmap( aDestBmpSize, aSrcBitmap.GetBitCount(), &pReadAccess->GetPalette() );
+ Bitmap aDstBitmap(aDestBmpSize, aSrcBitmap.getPixelFormat(), &pReadAccess->GetPalette());
Bitmap aDstAlpha( AlphaMask( aDestBmpSize ).GetBitmap() );
{
@@ -964,7 +977,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un
aPalette[0] = BitmapColor(aColorBack);
aPalette[1] = BitmapColor(aColorPix);
- Bitmap aBitmap(Size(8, 8), 1, &aPalette);
+ Bitmap aBitmap(Size(8, 8), vcl::PixelFormat::N1_BPP, &aPalette);
BitmapScopedWriteAccess pContent(aBitmap);
for(sal_uInt16 a(0); a < 8; a++)
@@ -1071,7 +1084,7 @@ bool convertBitmap32To24Plus8(BitmapEx const & rInput, BitmapEx & rResult)
return false;
Size aSize = aBitmap.GetSizePixel();
- Bitmap aResultBitmap(aSize, 24);
+ Bitmap aResultBitmap(aSize, vcl::PixelFormat::N24_BPP);
AlphaMask aResultAlpha(aSize);
{
BitmapScopedWriteAccess pResultBitmapAccess(aResultBitmap);
diff --git a/vcl/source/bitmap/alpha.cxx b/vcl/source/bitmap/alpha.cxx
index fb1402f5ad9e..1c67a8cdbcc1 100644
--- a/vcl/source/bitmap/alpha.cxx
+++ b/vcl/source/bitmap/alpha.cxx
@@ -39,8 +39,8 @@ AlphaMask::AlphaMask( const AlphaMask& ) = default;
AlphaMask::AlphaMask( AlphaMask&& ) = default;
-AlphaMask::AlphaMask( const Size& rSizePixel, const sal_uInt8* pEraseTransparency ) :
- Bitmap( rSizePixel, 8, &Bitmap::GetGreyPalette( 256 ) )
+AlphaMask::AlphaMask( const Size& rSizePixel, const sal_uInt8* pEraseTransparency )
+ : Bitmap(rSizePixel, vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256))
{
if( pEraseTransparency )
Bitmap::Erase( Color( *pEraseTransparency, *pEraseTransparency, *pEraseTransparency ) );
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index 7210a20a5e16..caf589149382 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -74,7 +74,7 @@ Bitmap::Bitmap(std::shared_ptr<SalBitmap> const & pSalBitmap)
{
}
-Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal )
+Bitmap::Bitmap( const Size& rSizePixel, vcl::PixelFormat ePixelFormat, const BitmapPalette* pPal )
{
if (!(rSizePixel.Width() && rSizePixel.Height()))
return;
@@ -82,19 +82,20 @@ Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalett
BitmapPalette aPal;
BitmapPalette* pRealPal = nullptr;
- if( nBitCount <= 8 )
+ if (vcl::isPalettePixelFormat(ePixelFormat))
{
if( !pPal )
{
- if( 1 == nBitCount )
+ if (ePixelFormat == vcl::PixelFormat::N1_BPP)
{
aPal.SetEntryCount( 2 );
aPal[ 0 ] = COL_BLACK;
aPal[ 1 ] = COL_WHITE;
}
- else if( ( 4 == nBitCount ) || ( 8 == nBitCount ) )
+ else if (ePixelFormat == vcl::PixelFormat::N4_BPP ||
+ ePixelFormat == vcl::PixelFormat::N8_BPP)
{
- aPal.SetEntryCount( 1 << nBitCount );
+ aPal.SetEntryCount(1 << sal_uInt16(ePixelFormat));
aPal[ 0 ] = COL_BLACK;
aPal[ 1 ] = COL_BLUE;
aPal[ 2 ] = COL_GREEN;
@@ -113,7 +114,7 @@ Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalett
aPal[ 15 ] = COL_WHITE;
// Create dither palette
- if( 8 == nBitCount )
+ if (ePixelFormat == vcl::PixelFormat::N8_BPP)
{
sal_uInt16 nActCol = 16;
@@ -132,7 +133,7 @@ Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalett
}
mxSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
- mxSalBmp->Create( rSizePixel, nBitCount, pRealPal ? *pRealPal : aPal );
+ mxSalBmp->Create( rSizePixel, sal_uInt16(ePixelFormat), pRealPal ? *pRealPal : aPal );
}
#ifdef DBG_UTIL
@@ -320,6 +321,21 @@ Size Bitmap::GetSizePixel() const
return( mxSalBmp ? mxSalBmp->GetSize() : Size() );
}
+vcl::PixelFormat Bitmap::getPixelFormat() const
+{
+ switch (GetBitCount())
+ {
+ case 1: return vcl::PixelFormat::N1_BPP;
+ case 4: return vcl::PixelFormat::N4_BPP;
+ case 8: return vcl::PixelFormat::N8_BPP;
+ case 24: return vcl::PixelFormat::N24_BPP;
+ case 32: return vcl::PixelFormat::N32_BPP;
+ default:
+ break;
+ }
+ return vcl::PixelFormat::INVALID;
+}
+
sal_uInt16 Bitmap::GetBitCount() const
{
if (!mxSalBmp)
@@ -427,7 +443,6 @@ void Bitmap::ReassignWithSize(const Bitmap& rBitmap)
maPrefMapMode = aOldMapMode;
}
-
void Bitmap::ImplSetSalBitmap(const std::shared_ptr<SalBitmap>& xImpBmp)
{
mxSalBmp = xImpBmp;
@@ -489,7 +504,7 @@ bool Bitmap::Crop( const tools::Rectangle& rRectPixel )
if( pReadAcc )
{
const tools::Rectangle aNewRect( Point(), aRect.GetSize() );
- Bitmap aNewBmp( aNewRect.GetSize(), GetBitCount(), &pReadAcc->GetPalette() );
+ Bitmap aNewBmp(aNewRect.GetSize(), getPixelFormat(), &pReadAcc->GetPalette());
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if( pWriteAcc )
@@ -869,7 +884,7 @@ bool Bitmap::Expand( sal_uLong nDX, sal_uLong nDY, const Color* pInitColor )
if( pReadAcc )
{
BitmapPalette aBmpPal( pReadAcc->GetPalette() );
- Bitmap aNewBmp( aNewSize, GetBitCount(), &aBmpPal );
+ Bitmap aNewBmp(aNewSize, getPixelFormat(), &aBmpPal);
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if( pWriteAcc )
@@ -990,9 +1005,9 @@ bool Bitmap::Convert( BmpConversion eConversion )
case BmpConversion::N4BitColors:
{
if( nBitCount < 4 )
- bRet = ImplConvertUp( 4 );
+ bRet = ImplConvertUp(vcl::PixelFormat::N4_BPP);
else if( nBitCount > 4 )
- bRet = ImplConvertDown( 4 );
+ bRet = ImplConvertDown(vcl::PixelFormat::N4_BPP);
else
bRet = true;
}
@@ -1006,9 +1021,9 @@ bool Bitmap::Convert( BmpConversion eConversion )
case BmpConversion::N8BitColors:
{
if( nBitCount < 8 )
- bRet = ImplConvertUp( 8 );
+ bRet = ImplConvertUp(vcl::PixelFormat::N8_BPP);
else if( nBitCount > 8 )
- bRet = ImplConvertDown( 8 );
+ bRet = ImplConvertDown(vcl::PixelFormat::N8_BPP);
else
bRet = true;
}
@@ -1019,16 +1034,16 @@ bool Bitmap::Convert( BmpConversion eConversion )
Color aTrans( BMP_COL_TRANS );
if( nBitCount < 8 )
- bRet = ImplConvertUp( 8, &aTrans );
+ bRet = ImplConvertUp(vcl::PixelFormat::N8_BPP, &aTrans );
else
- bRet = ImplConvertDown( 8, &aTrans );
+ bRet = ImplConvertDown(vcl::PixelFormat::N8_BPP, &aTrans );
}
break;
case BmpConversion::N24Bit:
{
if( nBitCount < 24 )
- bRet = ImplConvertUp( 24 );
+ bRet = ImplConvertUp(vcl::PixelFormat::N24_BPP);
else
bRet = true;
}
@@ -1037,7 +1052,7 @@ bool Bitmap::Convert( BmpConversion eConversion )
case BmpConversion::N32Bit:
{
if( nBitCount < 32 )
- bRet = ImplConvertUp( 32 );
+ bRet = ImplConvertUp(vcl::PixelFormat::N32_BPP);
else
bRet = true;
}
@@ -1069,7 +1084,9 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
if( bPalDiffers )
{
- Bitmap aNewBmp( GetSizePixel(), ( nGreys == 16 ) ? 4 : 8, &rPal );
+ auto ePixelFormat = nGreys == 16 ? vcl::PixelFormat::N4_BPP
+ : vcl::PixelFormat::N8_BPP;
+ Bitmap aNewBmp(GetSizePixel(), ePixelFormat, &rPal );
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if( pWriteAcc )
@@ -1169,9 +1186,9 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys )
return bRet;
}
-bool Bitmap::ImplConvertUp(sal_uInt16 nBitCount, Color const * pExtColor)
+bool Bitmap::ImplConvertUp(vcl::PixelFormat ePixelFormat, Color const * pExtColor)
{
- SAL_WARN_IF( nBitCount <= GetBitCount(), "vcl", "New BitCount must be greater!" );
+ SAL_WARN_IF(sal_Int32(ePixelFormat) <= GetBitCount(), "vcl", "New BitCount must be greater!" );
Bitmap::ScopedReadAccess pReadAcc(*this);
bool bRet = false;
@@ -1179,7 +1196,7 @@ bool Bitmap::ImplConvertUp(sal_uInt16 nBitCount, Color const * pExtColor)
if (pReadAcc)
{
BitmapPalette aPalette;
- Bitmap aNewBmp(GetSizePixel(), nBitCount, pReadAcc->HasPalette() ? &pReadAcc->GetPalette() : &aPalette);
+ Bitmap aNewBmp(GetSizePixel(), ePixelFormat, pReadAcc->HasPalette() ? &pReadAcc->GetPalette() : &aPalette);
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
@@ -1192,8 +1209,8 @@ bool Bitmap::ImplConvertUp(sal_uInt16 nBitCount, Color const * pExtColor)
const BitmapPalette& rOldPalette = pReadAcc->GetPalette();
const sal_uInt16 nOldCount = rOldPalette.GetEntryCount();
assert(nOldCount <= (1 << GetBitCount()));
-
- aPalette.SetEntryCount(1 << nBitCount);
+ sal_Int16 nNewBitCount = sal_Int16(ePixelFormat);
+ aPalette.SetEntryCount(1 << nNewBitCount);
for (sal_uInt16 i = 0; i < nOldCount; i++)
aPalette[i] = rOldPalette[i];
@@ -1258,9 +1275,9 @@ bool Bitmap::ImplConvertUp(sal_uInt16 nBitCount, Color const * pExtColor)
return bRet;
}
-bool Bitmap::ImplConvertDown(sal_uInt16 nBitCount, Color const * pExtColor)
+bool Bitmap::ImplConvertDown(vcl::PixelFormat ePixelFormat, Color const * pExtColor)
{
- SAL_WARN_IF(nBitCount > GetBitCount(), "vcl", "New BitCount must be lower ( or equal when pExtColor is set )!");
+ SAL_WARN_IF(sal_Int32(ePixelFormat) > GetBitCount(), "vcl", "New BitCount must be lower ( or equal when pExtColor is set )!");
Bitmap::ScopedReadAccess pReadAcc(*this);
bool bRet = false;
@@ -1268,12 +1285,13 @@ bool Bitmap::ImplConvertDown(sal_uInt16 nBitCount, Color const * pExtColor)
if (pReadAcc)
{
BitmapPalette aPalette;
- Bitmap aNewBmp(GetSizePixel(), nBitCount, &aPalette);
+ Bitmap aNewBmp(GetSizePixel(), ePixelFormat, &aPalette);
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
{
- const sal_uInt16 nCount = 1 << nBitCount;
+ sal_Int16 nNewBitCount = sal_Int16(ePixelFormat);
+ const sal_uInt16 nCount = 1 << nNewBitCount;
const tools::Long nWidth = pWriteAcc->Width();
const tools::Long nWidth1 = nWidth - 1;
const tools::Long nHeight = pWriteAcc->Height();
@@ -1581,7 +1599,7 @@ bool Bitmap::Dither()
if( ( aSize.Width() > 3 ) && ( aSize.Height() > 2 ) )
{
ScopedReadAccess pReadAcc(*this);
- Bitmap aNewBmp( GetSizePixel(), 8 );
+ Bitmap aNewBmp(GetSizePixel(), vcl::PixelFormat::N8_BPP);
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if( pReadAcc && pWriteAcc )
{
diff --git a/vcl/source/bitmap/bitmappaint.cxx b/vcl/source/bitmap/bitmappaint.cxx
index ad20832022d5..c2d79db69580 100644
--- a/vcl/source/bitmap/bitmappaint.cxx
+++ b/vcl/source/bitmap/bitmappaint.cxx
@@ -308,7 +308,7 @@ bool Bitmap::Rotate(Degree10 nAngle10, const Color& rFillColor)
if (nAngle10 == 900_deg10 || nAngle10 == 2700_deg10)
{
const Size aNewSizePix(aSizePix.Height(), aSizePix.Width());
- Bitmap aNewBmp(aNewSizePix, GetBitCount(), &pReadAcc->GetPalette());
+ Bitmap aNewBmp(aNewSizePix, getPixelFormat(), &pReadAcc->GetPalette());
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
@@ -360,7 +360,7 @@ bool Bitmap::Rotate(Degree10 nAngle10, const Color& rFillColor)
tools::Rectangle aNewBound(aPoly.GetBoundRect());
const Size aNewSizePix(aNewBound.GetSize());
- Bitmap aNewBmp(aNewSizePix, GetBitCount(), &pReadAcc->GetPalette());
+ Bitmap aNewBmp(aNewSizePix, getPixelFormat(), &pReadAcc->GetPalette());
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
if (pWriteAcc)
@@ -460,7 +460,8 @@ Bitmap Bitmap::CreateMask(const Color& rTransColor, sal_uInt8 nTol) const
return *this;
}
- Bitmap aNewBmp(GetSizePixel(), use8BitMask ? 8 : 1,
+ auto ePixelFormat = use8BitMask ? vcl::PixelFormat::N8_BPP : vcl::PixelFormat::N1_BPP;
+ Bitmap aNewBmp(GetSizePixel(), ePixelFormat,
use8BitMask ? &Bitmap::GetGreyPalette(256) : nullptr);
BitmapScopedWriteAccess pWriteAcc(aNewBmp);
bool bRet = false;
@@ -869,7 +870,7 @@ bool Bitmap::Replace(const Bitmap& rMask, const Color& rReplaceColor)
bool Bitmap::Replace(const AlphaMask& rAlpha, const Color& rMergeColor)
{
- Bitmap aNewBmp(GetSizePixel(), 24);
+ Bitmap aNewBmp(GetSizePixel(), vcl::PixelFormat::N24_BPP);
ScopedReadAccess pAcc(*this);
AlphaMask::ScopedReadAccess pAlphaAcc(const_cast<AlphaMask&>(rAlpha));
BitmapScopedWriteAccess pNewAcc(aNewBmp);
diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx
index 8609215ce46e..c8d15815bd59 100644
--- a/vcl/source/bitmap/dibtools.cxx
+++ b/vcl/source/bitmap/dibtools.cxx
@@ -136,11 +136,12 @@ struct DIBV5Header : public DIBInfoHeader
{}
};
-sal_uInt16 discretizeBitcount( sal_uInt16 nInputCount )
+vcl::PixelFormat convertToBPP(sal_uInt16 nCount)
{
- return ( nInputCount <= 1 ) ? 1 :
- ( nInputCount <= 4 ) ? 4 :
- ( nInputCount <= 8 ) ? 8 : 24;
+ return (nCount <= 1) ? vcl::PixelFormat::N1_BPP :
+ (nCount <= 4) ? vcl::PixelFormat::N4_BPP :
+ (nCount <= 8) ? vcl::PixelFormat::N8_BPP :
+ vcl::PixelFormat::N24_BPP;
}
bool isBitfieldCompression( ScanlineFormat nScanlineFormat )
@@ -998,20 +999,21 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL
pAccAlpha = AlphaScopedWriteAccess(aNewBmpAlpha);
}
- sal_uInt16 nBitCount(discretizeBitcount(aHeader.nBitCount));
+ vcl::PixelFormat ePixelFormat(convertToBPP(aHeader.nBitCount));
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 = (nBitCount == 8 && !!aPalette && aPalette.IsGreyPalette8Bit());
- const bool bForceToMonoWhileReading = (bIsMask && !bIsAlpha && nBitCount != 1);
+ 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;
- nBitCount = 1;
+ ePixelFormat = vcl::PixelFormat::N1_BPP;
SAL_WARN( "vcl", "forcing mask to monochrome");
}
- Bitmap aNewBmp(aSizePixel, nBitCount, pPal);
+ Bitmap aNewBmp(aSizePixel, ePixelFormat, pPal);
BitmapScopedWriteAccess pAcc(aNewBmp);
if (!pAcc)
return false;
@@ -1283,8 +1285,8 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead
// bitmaps is relatively recent.
// #i59239# discretize bitcount for aligned width to 1,4,8,24
// (other cases are not written below)
- const sal_uInt16 nBitCount(pAccAlpha ? 32 : discretizeBitcount(rAcc.GetBitCount()));
- const sal_uLong nAlignedWidth(AlignedWidth4Bytes(rAcc.Width() * nBitCount));
+ const auto ePixelFormat(pAccAlpha ? vcl::PixelFormat::N32_BPP : convertToBPP(rAcc.GetBitCount()));
+ const sal_uLong nAlignedWidth(AlignedWidth4Bytes(rAcc.Width() * sal_Int32(ePixelFormat)));
bool bNative(false);
switch(rAcc.GetScanlineFormat())
@@ -1319,9 +1321,9 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead
const tools::Long nWidth(rAcc.Width());
const tools::Long nHeight(rAcc.Height());
std::vector<sal_uInt8> aBuf(nAlignedWidth);
- switch( nBitCount )
+ switch(ePixelFormat)
{
- case 1:
+ case vcl::PixelFormat::N1_BPP:
{
//valgrind, zero out the trailing unused alignment bytes
size_t nUnusedBytes = nAlignedWidth - ((nWidth+7) / 8);
@@ -1351,7 +1353,7 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead
}
break;
- case 4:
+ case vcl::PixelFormat::N4_BPP:
{
//valgrind, zero out the trailing unused alignment bytes
size_t nUnusedBytes = nAlignedWidth - ((nWidth+1) / 2);
@@ -1380,7 +1382,7 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead
}
break;
- case 8:
+ case vcl::PixelFormat::N8_BPP:
{
for( tools::Long nY = nHeight - 1; nY >= 0; nY-- )
{
@@ -1395,7 +1397,7 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead
}
break;
- case 24:
+ case vcl::PixelFormat::N24_BPP:
{
//valgrind, zero out the trailing unused alignment bytes
size_t nUnusedBytes = nAlignedWidth - nWidth * 3;
@@ -1406,7 +1408,7 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead
default:
{
BitmapColor aPixelColor;
- const bool bWriteAlpha(32 == nBitCount && pAccAlpha);
+ const bool bWriteAlpha(ePixelFormat == vcl::PixelFormat::N32_BPP && pAccAlpha);
for( tools::Long nY = nHeight - 1; nY >= 0; nY-- )
{
@@ -1473,20 +1475,16 @@ bool ImplWriteDIBBody(const Bitmap& rBitmap, SvStream& rOStm, BitmapReadAccess c
// recent.
// #i59239# discretize bitcount to 1,4,8,24 (other cases
// are not written below)
- const sal_uInt16 nBitCount(pAccAlpha ? 32 : discretizeBitcount(rAcc.GetBitCount()));
- aHeader.nBitCount = nBitCount;
+ const auto ePixelFormat(pAccAlpha ? vcl::PixelFormat::N32_BPP : convertToBPP(rAcc.GetBitCount()));
+ aHeader.nBitCount = sal_uInt16(ePixelFormat);
aHeader.nSizeImage = rAcc.Height() * AlignedWidth4Bytes(rAcc.Width() * aHeader.nBitCount);
if(bCompressed)
{
- if(4 == nBitCount)
- {
+ if (ePixelFormat == vcl::PixelFormat::N4_BPP)
nCompression = RLE_4;
- }
- else if(8 == nBitCount)
- {
+ else if (ePixelFormat == vcl::PixelFormat::N8_BPP)
nCompression = RLE_8;
- }
}
}
diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx
index 72cb9a7495d1..85b4ea910071 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, 1);
+ aBmp1 = Bitmap(aSize, vcl::PixelFormat::N1_BPP);
if (!aAnimation.Count())
aBmp1.Erase(aWhite);
@@ -239,7 +239,7 @@ void GIFReader::CreateBitmaps(tools::Long nWidth, tools::Long nHeight, BitmapPal
if (bStatus)
{
- aBmp8 = Bitmap(aSize, 8, pPal);
+ aBmp8 = Bitmap(aSize, vcl::PixelFormat::N8_BPP, pPal);
if (!!aBmp8 && bWatchForBackgroundColor && aAnimation.Count())
aBmp8.Erase((*pPal)[nBackgroundColor]);
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index a9b8b1b8630e..c51d350e3dda 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -182,7 +182,7 @@ size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector<BitmapEx>& r
/*start_y=*/0, nPageWidth, nPageHeight);
// Save the buffer as a bitmap.
- Bitmap aBitmap(Size(nPageWidth, nPageHeight), 24);
+ Bitmap aBitmap(Size(nPageWidth, nPageHeight), vcl::PixelFormat::N24_BPP);
AlphaMask aMask(Size(nPageWidth, nPageHeight));
{
BitmapScopedWriteAccess pWriteAccess(aBitmap);
diff --git a/vcl/source/filter/itiff/itiff.cxx b/vcl/source/filter/itiff/itiff.cxx
index 21dc6a4adfe8..906826ae9e55 100644
--- a/vcl/source/filter/itiff/itiff.cxx
+++ b/vcl/source/filter/itiff/itiff.cxx
@@ -1675,7 +1675,7 @@ bool TIFFReader::ReadTIFF(SvStream & rTIFF, Graphic & rGraphic )
{
BitmapEx aImage = vcl::bitmap::CreateFromData(maBitmap.data(), nImageWidth, nImageLength,
nImageWidth * (HasAlphaChannel() ? 4 : 3), // scanline bytes
- HasAlphaChannel() ? 32 : 24);
+ HasAlphaChannel() ? vcl::PixelFormat::N32_BPP : vcl::PixelFormat::N24_BPP);
aImage.SetPrefMapMode(maBitmapPrefMapMode);
aImage.SetPrefSize(maBitmapPrefSize);
diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx
index 1cbb69fdb940..9368f9f9a885 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 ), 1 );
+ aBmp1 = Bitmap(Size(nWidth, nHeight), vcl::PixelFormat::N1_BPP);
pAcc1 = BitmapScopedWriteAccess(aBmp1);
if( pAcc1 )
@@ -349,7 +349,7 @@ ReadState XBMReader::ReadXBM( Graphic& rGraphic )
if (bStatus && pAcc1)
{
- Bitmap aBlackBmp( Size( pAcc1->Width(), pAcc1->Height() ), 1 );
+ Bitmap aBlackBmp(Size(pAcc1->Width(), pAcc1->Height()), vcl::PixelFormat::N1_BPP);
pAcc1.reset();
aBlackBmp.Erase( COL_BLACK );
diff --git a/vcl/source/filter/ixpm/xpmread.cxx b/vcl/source/filter/ixpm/xpmread.cxx
index e96a097da0da..24e9cacb4fbe 100644
--- a/vcl/source/filter/ixpm/xpmread.cxx
+++ b/vcl/source/filter/ixpm/xpmread.cxx
@@ -193,23 +193,23 @@ ReadState XPMReader::ReadXPM( Graphic& rGraphic )
if ( mbStatus )
{
// create a 24bit graphic when more as 256 colours present
- sal_uInt16 nBits = 1;
+ auto ePixelFormat = vcl::PixelFormat::INVALID;
if ( mnColors > 256 )
- nBits = 24;
+ ePixelFormat = vcl::PixelFormat::N24_BPP;
else if ( mnColors > 16 )
- nBits = 8;
+ ePixelFormat = vcl::PixelFormat::N8_BPP;
else if ( mnColors > 2 )
- nBits = 4;
+ ePixelFormat = vcl::PixelFormat::N4_BPP;
else
- nBits = 1;
+ ePixelFormat = vcl::PixelFormat::N1_BPP;
- maBmp = Bitmap( Size( mnWidth, mnHeight ), nBits );
+ maBmp = Bitmap(Size(mnWidth, mnHeight), ePixelFormat);
mpAcc = BitmapScopedWriteAccess(maBmp);
// mbTransparent is TRUE if at least one colour is transparent
if ( mbTransparent )
{
- maMaskBmp = Bitmap( Size( mnWidth, mnHeight ), 1 );
+ maMaskBmp = Bitmap(Size(mnWidth, mnHeight), vcl::PixelFormat::N1_BPP);
mpMaskAcc = BitmapScopedWriteAccess(maMaskBmp);
if ( !mpMaskAcc )
mbStatus = false;
diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx
index 80e956925c2b..026ff1640428 100644
--- a/vcl/source/filter/jpeg/JpegReader.cxx
+++ b/vcl/source/filter/jpeg/JpegReader.cxx
@@ -216,11 +216,11 @@ bool JPEGReader::CreateBitmap(JPEGCreateBitmapParam const & rParam)
aGrayPal[ n ] = BitmapColor( cGray, cGray, cGray );
}
- mpBitmap.reset(new Bitmap(aSize, 8, &aGrayPal));
+ mpBitmap.reset(new Bitmap(aSize, vcl::PixelFormat::N8_BPP, &aGrayPal));
}
else
{
- mpBitmap.reset(new Bitmap(aSize, 24));
+ mpBitmap.reset(new Bitmap(aSize, vcl::PixelFormat::N24_BPP));
}
if (mbSetLogSize)
@@ -249,7 +249,7 @@ Graphic JPEGReader::CreateIntermediateGraphic(tools::Long nLines)
if (!mnLastLines)
{
- mpIncompleteAlpha.reset(new Bitmap(aSizePixel, 1));
+ mpIncompleteAlpha.reset(new Bitmap(aSizePixel, vcl::PixelFormat::N1_BPP));
mpIncompleteAlpha->Erase(COL_WHITE);
}
diff --git a/vcl/source/filter/png/PngImageReader.cxx b/vcl/source/filter/png/PngImageReader.cxx
index b385ba90a508..b1e8e10cdc1d 100644
--- a/vcl/source/filter/png/PngImageReader.cxx
+++ b/vcl/source/filter/png/PngImageReader.cxx
@@ -187,7 +187,7 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx, bool bUseBitmap32)
{
size_t aRowSizeBytes = png_get_rowbytes(pPng, pInfo);
- aBitmap = Bitmap(Size(width, height), 24);
+ aBitmap = Bitmap(Size(width, height), vcl::PixelFormat::N24_BPP);
{
pWriteAccess = BitmapScopedWriteAccess(aBitmap);
ScanlineFormat eFormat = pWriteAccess->GetScanlineFormat();
@@ -224,7 +224,7 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx, bool bUseBitmap32)
if (bUseBitmap32)
{
- aBitmap = Bitmap(Size(width, height), 32);
+ aBitmap = Bitmap(Size(width, height), vcl::PixelFormat::N32_BPP);
{
pWriteAccess = BitmapScopedWriteAccess(aBitmap);
ScanlineFormat eFormat = pWriteAccess->GetScanlineFormat();
@@ -271,7 +271,7 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx, bool bUseBitmap32)
}
else
{
- aBitmap = Bitmap(Size(width, height), 24);
+ aBitmap = Bitmap(Size(width, height), vcl::PixelFormat::N24_BPP);
aBitmapAlpha = AlphaMask(Size(width, height), nullptr);
{
pWriteAccess = BitmapScopedWriteAccess(aBitmap);
@@ -314,7 +314,8 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx, bool bUseBitmap32)
{
size_t aRowSizeBytes = png_get_rowbytes(pPng, pInfo);
- aBitmap = Bitmap(Size(width, height), 8, &Bitmap::GetGreyPalette(256));
+ aBitmap = Bitmap(Size(width, height), vcl::PixelFormat::N8_BPP,
+ &Bitmap::GetGreyPalette(256));
aBitmap.Erase(COL_WHITE);
{
pWriteAccess = BitmapScopedWriteAccess(aBitmap);
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 96df06275afc..110485abf4e6 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -1776,7 +1776,7 @@ BitmapEx GDIMetaFile::ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpPa
aPal[ 1 ] = COL_WHITE;
aPal[ 2 ] = static_cast<const ImplBmpMonoParam*>(pBmpParam)->aColor;
- Bitmap aBmp( rBmpEx.GetSizePixel(), 4, &aPal );
+ Bitmap aBmp(rBmpEx.GetSizePixel(), vcl::PixelFormat::N4_BPP, &aPal);
aBmp.Erase( static_cast<const ImplBmpMonoParam*>(pBmpParam)->aColor );
if( rBmpEx.IsAlpha() )
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 55c0bbdeaac8..c5e29a47cd74 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -233,7 +233,7 @@ void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask,
// we always want to have a mask
if( aMask.IsEmpty() )
{
- aMask = Bitmap( aSrcRect.GetSize(), 1 );
+ aMask = Bitmap(aSrcRect.GetSize(), vcl::PixelFormat::N1_BPP);
aMask.Erase( COL_BLACK );
}
diff --git a/vcl/source/graphic/GraphicObject2.cxx b/vcl/source/graphic/GraphicObject2.cxx
index f2a67a6f8203..b9ac81baf1d1 100644
--- a/vcl/source/graphic/GraphicObject2.cxx
+++ b/vcl/source/graphic/GraphicObject2.cxx
@@ -465,7 +465,7 @@ void GraphicObject::ImplTransformBitmap( BitmapEx& rBmpEx,
else
{
// #104115# Generate mask bitmap and init to zero
- Bitmap aMask( aBmpSize, 1 );
+ Bitmap aMask(aBmpSize, vcl::PixelFormat::N1_BPP);
aMask.Erase( Color(0,0,0) );
// #104115# Always generate transparent bitmap, we need the border transparent
diff --git a/vcl/source/helper/canvastools.cxx b/vcl/source/helper/canvastools.cxx
index c1ee370537cc..54dd76ae7651 100644
--- a/vcl/source/helper/canvastools.cxx
+++ b/vcl/source/helper/canvastools.cxx
@@ -265,19 +265,24 @@ namespace vcl::unotools
sizeFromIntegerSize2D(xInputBitmap->getSize()));
// normalize bitcount
- nDepth =
- ( nDepth <= 1 ) ? 1 :
- ( nDepth <= 4 ) ? 4 :
- ( nDepth <= 8 ) ? 8 : 24;
+ auto ePixelFormat =
+ ( nDepth <= 1 ) ? vcl::PixelFormat::N1_BPP :
+ ( nDepth <= 4 ) ? vcl::PixelFormat::N4_BPP :
+ ( nDepth <= 8 ) ? vcl::PixelFormat::N8_BPP :
+ vcl::PixelFormat::N24_BPP;
+ auto eAlphaPixelFormat =
+ ( nAlphaDepth <= 1 ) ? vcl::PixelFormat::N1_BPP :
+ ( nAlphaDepth <= 4 ) ? vcl::PixelFormat::N4_BPP :
+ vcl::PixelFormat::N8_BPP;
::Bitmap aBitmap( aPixelSize,
- sal::static_int_cast<sal_uInt16>(nDepth),
+ ePixelFormat,
aLayout.Palette.is() ? &aPalette : nullptr );
::Bitmap aAlpha;
if( nAlphaDepth )
- aAlpha = ::Bitmap( aPixelSize,
- sal::static_int_cast<sal_uInt16>(nAlphaDepth),
- &::Bitmap::GetGreyPalette(
+ aAlpha = Bitmap(aPixelSize,
+ eAlphaPixelFormat,
+ &Bitmap::GetGreyPalette(
sal::static_int_cast<sal_uInt16>(1 << nAlphaDepth)) );
{ // limit scoped access
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 2d9d3ce8c713..d67e5c6fc59a 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -563,8 +563,8 @@ GLenum OpenGLHelper::OptimalBufferFormat()
BitmapEx OpenGLHelper::ConvertBufferToBitmapEx(const sal_uInt8* const pBuffer, tools::Long nWidth, tools::Long nHeight)
{
assert(pBuffer);
- Bitmap aBitmap( Size(nWidth, nHeight), 24 );
- AlphaMask aAlpha( Size(nWidth, nHeight) );
+ Bitmap aBitmap(Size(nWidth, nHeight), vcl::PixelFormat::N24_BPP);
+ AlphaMask aAlpha(Size(nWidth, nHeight));
{
BitmapScopedWriteAccess pWriteAccess( aBitmap );
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 426366580c4d..9162a67ef732 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -322,7 +322,7 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
{
if ( mnDrawMode & ( DrawModeFlags::BlackBitmap | DrawModeFlags::WhiteBitmap ) )
{
- Bitmap aColorBmp( aBmpEx.GetSizePixel(), 1 );
+ Bitmap aColorBmp(aBmpEx.GetSizePixel(), vcl::PixelFormat::N1_BPP);
sal_uInt8 cCmpVal;
if ( mnDrawMode & DrawModeFlags::BlackBitmap )
@@ -1568,7 +1568,7 @@ Bitmap OutputDevice::BlendBitmapWithAlpha(
if( GetBitCount() <= 8 )
{
- Bitmap aDither( aBmp.GetSizePixel(), 8 );
+ Bitmap aDither(aBmp.GetSizePixel(), vcl::PixelFormat::N8_BPP);
BitmapColor aIndex( 0 );
Bitmap::ScopedReadAccess pB(aBmp);
BitmapScopedWriteAccess pW(aDither);
@@ -1661,7 +1661,7 @@ Bitmap OutputDevice::BlendBitmap(
if( GetBitCount() <= 8 )
{
- Bitmap aDither( aBmp.GetSizePixel(), 8 );
+ Bitmap aDither(aBmp.GetSizePixel(), vcl::PixelFormat::N8_BPP);
BitmapColor aIndex( 0 );
Bitmap::ScopedReadAccess pB(aBmp);
BitmapScopedWriteAccess pW(aDither);
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 562e0d474f7d..53bf57e3aa8a 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -946,7 +946,7 @@ BitmapChecksum PDFiumPageImpl::getChecksum(int nMDPPerm)
FPDF_RenderPageBitmap(pPdfBitmap->getPointer(), mpPage, /*start_x=*/0, /*start_y=*/0,
nPageWidth, nPageHeight,
/*rotate=*/0, nFlags);
- Bitmap aBitmap(Size(nPageWidth, nPageHeight), 24);
+ Bitmap aBitmap(Size(nPageWidth, nPageHeight), vcl::PixelFormat::N24_BPP);
{
BitmapScopedWriteAccess pWriteAccess(aBitmap);
const auto pPdfBuffer
diff --git a/vcl/workben/svptest.cxx b/vcl/workben/svptest.cxx
index 69b8d3a08adc..6bab8611149f 100644
--- a/vcl/workben/svptest.cxx
+++ b/vcl/workben/svptest.cxx
@@ -105,7 +105,7 @@ void Main()
MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) :
WorkWindow( pParent, nWinStyle ),
- m_aBitmap( Size( 256, 256 ), 32 )
+ m_aBitmap(Size(256, 256), vcl::PixelFormat::N32_BPP)
{
// prepare an alpha mask
BitmapWriteAccess* pAcc = m_aBitmap.AcquireWriteAccess();
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index e37ac96eba9b..1a877bfa794a 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -855,7 +855,7 @@ public:
aRight.Crop(tools::Rectangle(Point((nSlice * 3) + 3, (nSlice * 2) + 1),
Size(nSlice, 1)));
AlphaMask aAlphaMask(aRight.GetBitmap());
- Bitmap aBlockColor(aAlphaMask.GetSizePixel(), 24);
+ Bitmap aBlockColor(aAlphaMask.GetSizePixel(), vcl::PixelFormat::N24_BPP);
aBlockColor.Erase(COL_RED);
BitmapEx aShadowStretch(aBlockColor, aAlphaMask);
@@ -874,7 +874,7 @@ public:
}
AlphaMask aWholeMask(aPageShadowMask.GetBitmap());
- aBlockColor = Bitmap(aPageShadowMask.GetSizePixel(), 24);
+ aBlockColor = Bitmap(aPageShadowMask.GetSizePixel(), vcl::PixelFormat::N24_BPP);
aBlockColor.Erase(COL_GREEN);
BitmapEx aWhole(aBlockColor, aWholeMask);
@@ -1300,7 +1300,7 @@ public:
Bitmap aWhiteBmp = aWhite->GetBitmap(Point(),aSrc.GetSizePixel());
Bitmap aBlackBmp = aBlack->GetBitmap(Point(),aSrc.GetSizePixel());
AlphaMask aMask(aSrc.GetSizePixel());
- Bitmap aRecovered(aSrc.GetSizePixel(), 24);
+ Bitmap aRecovered(aSrc.GetSizePixel(), vcl::PixelFormat::N24_BPP);
{
AlphaScopedWriteAccess pMaskAcc(aMask);
BitmapScopedWriteAccess pRecAcc(aRecovered);