diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/bitmapcolor.cxx | 48 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapTools.cxx | 13 | ||||
-rw-r--r-- | vcl/source/gdi/bmpacc2.cxx | 6 | ||||
-rw-r--r-- | vcl/unx/generic/print/genpspgraphics.cxx | 6 |
4 files changed, 44 insertions, 29 deletions
diff --git a/vcl/qa/cppunit/bitmapcolor.cxx b/vcl/qa/cppunit/bitmapcolor.cxx index 2953c0d0eab8..c8cae6aef973 100644 --- a/vcl/qa/cppunit/bitmapcolor.cxx +++ b/vcl/qa/cppunit/bitmapcolor.cxx @@ -35,9 +35,8 @@ public: void defaultConstructor(); void colorValueConstructor(); void colorClassConstructor(); - + void getColor(); void setValue(); - void invert(); void getLuminance(); @@ -45,6 +44,7 @@ public: CPPUNIT_TEST(defaultConstructor); CPPUNIT_TEST(colorValueConstructor); CPPUNIT_TEST(colorClassConstructor); + CPPUNIT_TEST(getColor); CPPUNIT_TEST(setValue); CPPUNIT_TEST(invert); CPPUNIT_TEST(getLuminance); @@ -58,7 +58,7 @@ void BitmapColorTest::defaultConstructor() CPPUNIT_ASSERT_EQUAL_MESSAGE("Red wrong", static_cast<sal_uInt8>(0), aBmpColor.GetRed()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0), aBmpColor.GetAlpha()); } void BitmapColorTest::colorValueConstructor() @@ -70,7 +70,8 @@ void BitmapColorTest::colorValueConstructor() CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0), + aBmpColor.GetAlpha()); } { @@ -81,7 +82,8 @@ void BitmapColorTest::colorValueConstructor() aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(128), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0), + aBmpColor.GetAlpha()); } { @@ -92,7 +94,8 @@ void BitmapColorTest::colorValueConstructor() aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(255), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0), + aBmpColor.GetAlpha()); } } @@ -106,7 +109,8 @@ void BitmapColorTest::colorClassConstructor() CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(0), aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0), + aBmpColor.GetAlpha()); } { @@ -118,7 +122,8 @@ void BitmapColorTest::colorClassConstructor() aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(127), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0), + aBmpColor.GetAlpha()); } { @@ -130,10 +135,35 @@ void BitmapColorTest::colorClassConstructor() aBmpColor.GetGreen()); CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(255), aBmpColor.GetBlue()); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Index wrong", false, aBmpColor.IsIndex()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(0), + aBmpColor.GetAlpha()); + } + + // Transparency / Alpha + { + Color aColor(255, 128, 64, 0); + BitmapColor aBmpColor(aColor); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Red wrong", static_cast<sal_uInt8>(128), aBmpColor.GetRed()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", static_cast<sal_uInt8>(64), + aBmpColor.GetGreen()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", static_cast<sal_uInt8>(0), aBmpColor.GetBlue()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Alpha wrong", static_cast<sal_uInt8>(255), + aBmpColor.GetAlpha()); } } +void BitmapColorTest::getColor() +{ + BitmapColor aBitmapColor(255, 128, 64, 32); + Color aColor = aBitmapColor.GetColor(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Red wrong", sal_uInt8(255), aColor.GetRed()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Green wrong", sal_uInt8(128), aColor.GetGreen()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Blue wrong", sal_uInt8(64), aColor.GetBlue()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Transparecy wrong", sal_uInt8(32), aColor.GetTransparency()); +} + void BitmapColorTest::setValue() { BitmapColor aBmpColor; diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index aaa678b888dd..13a133295b06 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -652,18 +652,7 @@ css::uno::Sequence< sal_Int8 > GetMaskDIB(BitmapEx const & aBmpEx) static sal_uInt8 lcl_GetColor(BitmapColor const& rColor) { - sal_uInt8 nTemp(0); - if (rColor.IsIndex()) - { - nTemp = rColor.GetIndex(); - } - else - { - nTemp = rColor.GetBlue(); - // greyscale expected here, or what would non-grey colors mean? - assert(rColor.GetRed() == nTemp && rColor.GetGreen() == nTemp); - } - return nTemp; + return rColor.GetBlueOrIndex(); } diff --git a/vcl/source/gdi/bmpacc2.cxx b/vcl/source/gdi/bmpacc2.cxx index 1d7cec5f4c79..25606c09509e 100644 --- a/vcl/source/gdi/bmpacc2.cxx +++ b/vcl/source/gdi/bmpacc2.cxx @@ -79,11 +79,7 @@ BitmapColor BitmapReadAccess::GetPixelForN8BitPal(ConstScanline pScanline, long void BitmapReadAccess::SetPixelForN8BitPal(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&) { - if (rBitmapColor.IsIndex()) - pScanline[ nX ] = rBitmapColor.GetIndex(); - else - // Let's hope that the RGB color values equal, so it doesn't matter what do we pick - pScanline[ nX ] = rBitmapColor.GetBlueOrIndex(); + pScanline[ nX ] = rBitmapColor.GetBlueOrIndex(); } BitmapColor BitmapReadAccess::GetPixelForN8BitTcMask(ConstScanline pScanline, long nX, const ColorMask& rMask) diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index f74ecffdb990..88e7fcdf901a 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -192,7 +192,7 @@ SalPrinterBmp::GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const Scanline pScan = mpScanAccess + nRow * mnScanOffset; BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask); - if (aColor.IsIndex()) + if (!!mpBmpBuffer->maPalette) GetPaletteColor(aColor.GetIndex()); return ((aColor.GetBlue()) & 0x000000ff) @@ -206,7 +206,7 @@ SalPrinterBmp::GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const Scanline pScan = mpScanAccess + nRow * mnScanOffset; BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask); - if (aColor.IsIndex()) + if (!!mpBmpBuffer->maPalette) aColor = mpBmpBuffer->maPalette[aColor.GetIndex()]; return ( aColor.GetBlue() * 28UL @@ -221,7 +221,7 @@ SalPrinterBmp::GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const Scanline pScan = mpScanAccess + nRow * mnScanOffset; BitmapColor aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask); - if (aColor.IsIndex()) + if (!!mpBmpBuffer->maPalette) return aColor.GetIndex(); else return 0; |