diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2018-01-21 04:48:50 +1100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-02-05 09:00:54 +0100 |
commit | 01e470f0ab49e458c57b0f28636a517b2bfb1b4a (patch) | |
tree | e153e55125b3d5682e60425b80568c5e03a3695a | |
parent | 79517c0471aff4abf336bd81834bd28732dad67f (diff) |
vcl: remove BitmapColor Color() operator
BitmapColor has a Color() operator. However, this is confusing and
tends to hide that the two classes aren't the same. I have converted this
to GetColor().
Change-Id: I0be2dcb3fc420e7be9c8d04330e7a3fe69a5412a
Reviewed-on: https://gerrit.libreoffice.org/48245
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
25 files changed, 180 insertions, 168 deletions
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index a25dac85acc6..bba59a15c475 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -470,7 +470,7 @@ namespace cairocanvas else nAlpha = data[ nOff + 3 ] = 255; #endif - aColor = pBitmapReadAcc->GetPaletteColor( *pReadScan++ ); + aColor = pBitmapReadAcc->GetPaletteColor(*pReadScan++).GetColor(); #ifdef OSL_BIGENDIAN data[ nOff++ ] = sal::static_int_cast<unsigned char>(( nAlpha*( aColor.GetRed() ) )/255 ); @@ -611,7 +611,7 @@ namespace cairocanvas for( nX = 0; nX < nWidth; nX++ ) { - aColor = pBitmapReadAcc->GetColor( nY, nX ); + aColor = pBitmapReadAcc->GetColor( nY, nX ).GetColor(); // cairo need premultiplied color values // TODO(rodo) handle endianness diff --git a/cppcanvas/qa/extras/emfplus/emfplus.cxx b/cppcanvas/qa/extras/emfplus/emfplus.cxx index b5a32b1fca94..fbc55d2f2181 100644 --- a/cppcanvas/qa/extras/emfplus/emfplus.cxx +++ b/cppcanvas/qa/extras/emfplus/emfplus.cxx @@ -80,7 +80,7 @@ void Test::testFdo77229() Bitmap aBitmap = load("fdo77229.emf"); Bitmap::ScopedReadAccess pAccess(aBitmap); // The green star was missing. - Color aColor(pAccess->GetPixel(142, 140)); + Color aColor(pAccess->GetPixel(142, 140).GetColor()); CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), aColor.GetRed()); CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), aColor.GetBlue()); CPPUNIT_ASSERT(aColor.GetGreen() == 0xfe || aColor.GetGreen() == 0xff); diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx index 687e44677825..6492ad558a3e 100644 --- a/cui/source/dialogs/colorpicker.cxx +++ b/cui/source/dialogs/colorpicker.cxx @@ -447,7 +447,7 @@ void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) if (pReadAccess != nullptr) { // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe - maColor = pReadAccess->GetPixel(nY, nX); + maColor = pReadAccess->GetPixel(nY, nX).GetColor(); Bitmap::ReleaseAccess(pReadAccess); pReadAccess = nullptr; } diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx index 5422e9c0334f..141bd052cc66 100644 --- a/cui/source/tabpages/tppattern.cxx +++ b/cui/source/tabpages/tppattern.cxx @@ -313,8 +313,8 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, ValueSet*, void) m_pCtlPixel->SetXBitmap(pGraphicObject->GetGraphic().GetBitmapEx()); - Color aPixelColor = aFront; - Color aBackColor = aBack; + Color aPixelColor = aFront.GetColor(); + Color aBackColor = aBack.GetColor(); m_pLbColor->SelectEntry( aPixelColor ); m_pLbBackgroundColor->SelectEntry( aBackColor ); diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx index 069759533cd5..fc8750199c8f 100644 --- a/drawinglayer/source/texture/texture3d.cxx +++ b/drawinglayer/source/texture/texture3d.cxx @@ -122,7 +122,7 @@ namespace drawinglayer { const BitmapColor aBitmapColor(mpReadBitmap->GetColor(rY, rX)); - if(maBitmapEx.GetTransparentColor() == aBitmapColor.operator Color()) + if(maBitmapEx.GetTransparentColor() == aBitmapColor.GetColor()) { return 255; } diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index b07351a3389e..04864986d674 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -1382,9 +1382,9 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co { Color aReadColor; if (pRead->HasPalette()) - aReadColor = pRead->GetPaletteColor(pRead->GetPixelIndex(y, x)); + aReadColor = pRead->GetPaletteColor(pRead->GetPixelIndex(y, x)).GetColor(); else - aReadColor = pRead->GetPixel(y, x); + aReadColor = pRead->GetPixel(y, x).GetColor(); if (aReadColor.GetColor() == 0) pWrite->SetPixelOnData(pScanline, x, aCol2); diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx index a13153934e73..30d59ba2c8da 100644 --- a/include/vcl/salbtype.hxx +++ b/include/vcl/salbtype.hxx @@ -119,7 +119,7 @@ public: inline sal_uInt8 GetIndex() const; inline void SetIndex( sal_uInt8 cIndex ); - operator Color() const; + Color GetColor() const; inline sal_uInt8 GetBlueOrIndex() const; @@ -445,10 +445,10 @@ inline void BitmapColor::SetIndex( sal_uInt8 cIndex ) mcBlueOrIndex = cIndex; } -inline BitmapColor::operator Color() const +inline Color BitmapColor::GetColor() const { assert( !mbIndex && "Pixel represents index into colortable" ); - return Color( mcRed, mcGreen, mcBlueOrIndex ); + return Color(mcRed, mcGreen, mcBlueOrIndex); } inline sal_uInt8 BitmapColor::GetBlueOrIndex() const diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 99d00151a8bb..9549076902e4 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -1376,7 +1376,7 @@ void SdImportTest::testTdf93124() { for (long nX = 34; nX < (34 + 43); ++nX) { - const Color aColor = pReadAccess->GetColor(nY, nX); + const Color aColor = pReadAccess->GetColor(nY, nX).GetColor(); if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff)) ++nNonWhiteCount; } @@ -1435,7 +1435,7 @@ void SdImportTest::testTdf99729() { for (long nY = 16; nY < (16 + 96); ++nY) { - const Color aColor = pRead->GetColor(nY, nX); + const Color aColor = pRead->GetColor(nY, nX).GetColor(); if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff)) ++nonwhitecounts[i]; } @@ -1858,7 +1858,7 @@ bool checkPatternValues(std::vector<sal_uInt8>& rExpected, Bitmap& rBitmap) { for (long x = 0; x < pAccess->Width(); ++x) { - Color aColor = pAccess->GetPixel(y, x); + Color aColor = pAccess->GetPixel(y, x).GetColor(); sal_uInt8 aValue = rExpected[y*8+x]; if (aValue == 1 && aColor != aFGColor) diff --git a/sd/source/ui/slidesorter/view/SlsFramePainter.cxx b/sd/source/ui/slidesorter/view/SlsFramePainter.cxx index 05c97f6a6c51..07027c1d1e18 100644 --- a/sd/source/ui/slidesorter/view/SlsFramePainter.cxx +++ b/sd/source/ui/slidesorter/view/SlsFramePainter.cxx @@ -82,7 +82,8 @@ void FramePainter::AdaptColor ( Bitmap::ScopedReadAccess pReadAccess(aBitmap); if (!pReadAccess) return; - const Color aSourceColor = pReadAccess->GetColor(0,0); + const BitmapColor aBmpSourceColor = pReadAccess->GetColor(0,0); + const Color aSourceColor = aBmpSourceColor.GetColor(); pReadAccess.reset(); // Erase the center bitmap. diff --git a/svtools/source/graphic/transformer.cxx b/svtools/source/graphic/transformer.cxx index 775dfb1b0239..d21f0755624a 100644 --- a/svtools/source/graphic/transformer.cxx +++ b/svtools/source/graphic/transformer.cxx @@ -70,63 +70,69 @@ void setAlpha( Bitmap& rBitmap, AlphaMask& rAlpha, sal_uInt8 cIndexFrom, sal_Int uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange( const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nColorFrom, sal_Int8 nTolerance, sal_Int32 nColorTo, sal_Int8 nAlphaTo ) { - const uno::Reference< uno::XInterface > xIFace( rxGraphic, uno::UNO_QUERY ); - ::Graphic aGraphic( *::unographic::Graphic::getImplementation( xIFace ) ); + const uno::Reference< uno::XInterface > xIFace(rxGraphic, uno::UNO_QUERY); + ::Graphic aGraphic(*::unographic::Graphic::getImplementation(xIFace)); + + BitmapColor aBmpColorFrom(static_cast< sal_uInt8 >(nColorFrom), static_cast< sal_uInt8 >(nColorFrom >> 8), static_cast< sal_uInt8 >(nColorFrom >> 16)); + BitmapColor aBmpColorTo( static_cast< sal_uInt8 >(nColorTo), static_cast< sal_uInt8 >(nColorTo >> 8), static_cast< sal_uInt8 >(nColorTo >> 16)); + + Color aColorFrom(aBmpColorFrom.GetColor()); + Color aColorTo(aBmpColorTo.GetColor()); - BitmapColor aColorFrom( static_cast< sal_uInt8 >( nColorFrom ), static_cast< sal_uInt8 >( nColorFrom >> 8 ), static_cast< sal_uInt8 >( nColorFrom >> 16 ) ); - BitmapColor aColorTo( static_cast< sal_uInt8 >( nColorTo ), static_cast< sal_uInt8 >( nColorTo >> 8 ), static_cast< sal_uInt8 >( nColorTo >> 16 ) ); - const sal_uInt8 cIndexFrom = aColorFrom.GetBlueOrIndex(); + const sal_uInt8 cIndexFrom = aBmpColorFrom.GetBlueOrIndex(); - if ( aGraphic.GetType() == GraphicType::Bitmap || aGraphic.GetType() == GraphicType::GdiMetafile ) + if (aGraphic.GetType() == GraphicType::Bitmap || aGraphic.GetType() == GraphicType::GdiMetafile) { - BitmapEx aBitmapEx( aGraphic.GetBitmapEx() ); - Bitmap aBitmap( aBitmapEx.GetBitmap() ); + BitmapEx aBitmapEx(aGraphic.GetBitmapEx()); + Bitmap aBitmap(aBitmapEx.GetBitmap()); - if ( aBitmapEx.IsAlpha() ) + if (aBitmapEx.IsAlpha()) { - AlphaMask aAlphaMask( aBitmapEx.GetAlpha() ); - setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo ); - aBitmap.Replace( aColorFrom, aColorTo, nTolerance ); - aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) ); + AlphaMask aAlphaMask(aBitmapEx.GetAlpha()); + setAlpha(aBitmap, aAlphaMask, cIndexFrom, nAlphaTo); + aBitmap.Replace(aColorFrom, aColorTo, nTolerance); + aGraphic = ::Graphic(BitmapEx(aBitmap, aAlphaMask)); } - else if ( aBitmapEx.IsTransparent() ) + else if (aBitmapEx.IsTransparent()) { - if ( nAlphaTo == sal::static_int_cast<sal_Int8>(0xff) ) + if (nAlphaTo == sal::static_int_cast< sal_Int8 >(0xff)) { - Bitmap aMask( aBitmapEx.GetMask() ); - Bitmap aMask2( aBitmap.CreateMask( aColorFrom, nTolerance ) ); - aMask.CombineSimple( aMask2, BmpCombine::Or ); - aBitmap.Replace( aColorFrom, aColorTo, nTolerance ); - aGraphic = ::Graphic( BitmapEx( aBitmap, aMask ) ); + Bitmap aMask(aBitmapEx.GetMask()); + Bitmap aMask2(aBitmap.CreateMask(aColorFrom, nTolerance)); + aMask.CombineSimple(aMask2, BmpCombine::Or); + aBitmap.Replace(aColorFrom, aColorTo, nTolerance); + aGraphic = ::Graphic(BitmapEx(aBitmap, aMask)); } else { - AlphaMask aAlphaMask( aBitmapEx.GetMask() ); - setAlpha( aBitmap, aAlphaMask, cIndexFrom, 0xff - nAlphaTo ); - aBitmap.Replace( aColorFrom, aColorTo, nTolerance ); - aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) ); + AlphaMask aAlphaMask(aBitmapEx.GetMask()); + setAlpha(aBitmap, aAlphaMask, cIndexFrom, 0xff - nAlphaTo); + aBitmap.Replace(aColorFrom, aColorTo, nTolerance); + aGraphic = ::Graphic(BitmapEx(aBitmap, aAlphaMask)); } } else { - if ( ( nAlphaTo == 0 ) || ( nAlphaTo == sal::static_int_cast<sal_Int8>(0xff) ) ) + if ((nAlphaTo == 0) || (nAlphaTo == sal::static_int_cast< sal_Int8 >(0xff))) { - Bitmap aMask( aBitmap.CreateMask( aColorFrom, nTolerance ) ); - aBitmap.Replace( aColorFrom, aColorTo, nTolerance ); - aGraphic = ::Graphic( BitmapEx( aBitmap, aMask ) ); + Bitmap aMask(aBitmap.CreateMask(aColorFrom, nTolerance)); + aBitmap.Replace(aColorFrom, aColorTo, nTolerance); + aGraphic = ::Graphic(BitmapEx(aBitmap, aMask)); } else { - AlphaMask aAlphaMask( aBitmapEx.GetSizePixel() ); - setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo ); - aBitmap.Replace( aColorFrom, aColorTo, nTolerance ); - aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) ); + AlphaMask aAlphaMask(aBitmapEx.GetSizePixel()); + setAlpha(aBitmap, aAlphaMask, cIndexFrom, nAlphaTo); + aBitmap.Replace(aColorFrom, aColorTo, nTolerance); + aGraphic = ::Graphic(BitmapEx(aBitmap, aAlphaMask)); } } } + ::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic(); - pUnoGraphic->init( aGraphic ); - uno::Reference< graphic::XGraphic > xRet( pUnoGraphic ); + pUnoGraphic->init(aGraphic); + uno::Reference< graphic::XGraphic > xRet(pUnoGraphic); + return xRet; } diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index 3cb0518df7a9..d7f47cc015bc 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -978,31 +978,27 @@ void SvxPixelCtl::LoseFocus() Control::LoseFocus(); } -void SvxPixelCtl::SetXBitmap( const BitmapEx& rBitmapEx ) +void SvxPixelCtl::SetXBitmap(const BitmapEx& rBitmapEx) { BitmapColor aBack; BitmapColor aFront; - if(isHistorical8x8(rBitmapEx, aBack, aFront)) + if (isHistorical8x8(rBitmapEx, aBack, aFront)) { Bitmap aBitmap(rBitmapEx.GetBitmap()); Bitmap::ScopedReadAccess pRead(aBitmap); - aBackgroundColor = aBack; - aPixelColor = aFront; + aBackgroundColor = aBack.GetColor(); + aPixelColor = aFront.GetColor(); for(sal_uInt16 i(0); i < nSquares; i++) { const BitmapColor aColor(pRead->GetColor(i/8, i%8)); - if(aColor == aBack) - { - *( pPixel + i ) = 0; - } + if (aColor == aBack) + *(pPixel + i) = 0; else - { - *( pPixel + i ) = 1; - } + *(pPixel + i) = 1; } } } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 45af79c763f5..bacdd60ea0cb 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -364,9 +364,9 @@ DECLARE_OOXMLEXPORT_TEST(testPictureWithSchemeColor, "picture-with-schemecolor.d CPPUNIT_ASSERT(pAccess); CPPUNIT_ASSERT_EQUAL(341L, pAccess->Width()); CPPUNIT_ASSERT_EQUAL(181L, pAccess->Height()); - Color aColor(pAccess->GetPixel(30, 120)); + Color aColor(pAccess->GetPixel(30, 120).GetColor()); CPPUNIT_ASSERT_EQUAL(aColor.GetColor(), RGB_COLORDATA( 0xb1, 0xc8, 0xdd )); - aColor = pAccess->GetPixel(130, 260); + aColor = pAccess->GetPixel(130, 260).GetColor(); CPPUNIT_ASSERT_EQUAL(aColor.GetColor(), RGB_COLORDATA( 0xb1, 0xc8, 0xdd )); } @@ -542,7 +542,7 @@ DECLARE_OOXMLEXPORT_TEST(testMsoBrightnessContrast, "msobrightnesscontrast.docx" CPPUNIT_ASSERT(pAccess); CPPUNIT_ASSERT_EQUAL(58L, pAccess->Width()); CPPUNIT_ASSERT_EQUAL(320L, pAccess->Height()); - Color aColor(pAccess->GetPixel(30, 20)); + Color aColor(pAccess->GetPixel(30, 20).GetColor()); CPPUNIT_ASSERT_EQUAL(aColor.GetColor(), RGB_COLORDATA( 0xce, 0xce, 0xce )); } diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx index 6c9c02a8edb0..256aede7e863 100644 --- a/vcl/backendtest/outputdevice/common.cxx +++ b/vcl/backendtest/outputdevice/common.cxx @@ -29,7 +29,7 @@ void checkValue(Bitmap::ScopedWriteAccess& pAccess, int x, int y, Color aExpecte int& nNumberOfQuirks, int& nNumberOfErrors, bool bQuirkMode, int nColorDeltaThresh = 0) { const bool bColorize = false; - Color aColor = pAccess->GetPixel(y, x); + Color aColor = pAccess->GetPixel(y, x).GetColor(); int nColorDelta = deltaColor(aColor, aExpected); if (nColorDelta <= nColorDeltaThresh) diff --git a/vcl/qa/cppunit/BitmapProcessorTest.cxx b/vcl/qa/cppunit/BitmapProcessorTest.cxx index f53019e5ddeb..d7f0b525d1b7 100644 --- a/vcl/qa/cppunit/BitmapProcessorTest.cxx +++ b/vcl/qa/cppunit/BitmapProcessorTest.cxx @@ -49,7 +49,7 @@ void BitmapProcessorTest::testDisabledImage() Bitmap aDisabledBitmap(aDisabledBitmapEx.GetBitmap()); { Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap); - Color aColor(pReadAccess->GetPixel(0, 0)); + Color aColor(pReadAccess->GetPixel(0, 0).GetColor()); CPPUNIT_ASSERT_EQUAL(ColorData(0x001E1E1E), aColor.GetColor()); } } diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index 242969d250f9..02bf3c2b9f25 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -95,7 +95,7 @@ void BitmapTest::testConvert() #endif CPPUNIT_ASSERT(!pReadAccess->HasPalette()); - Color aColor = pReadAccess->GetPixel(0, 0); + Color aColor = pReadAccess->GetPixel(0, 0).GetColor(); CPPUNIT_ASSERT_EQUAL(sal_Int32(204), sal_Int32(aColor.GetRed())); CPPUNIT_ASSERT_EQUAL(sal_Int32(204), sal_Int32(aColor.GetGreen())); CPPUNIT_ASSERT_EQUAL(sal_Int32(255), sal_Int32(aColor.GetBlue())); diff --git a/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx b/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx index 024316c9e739..64125245c82a 100644 --- a/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx +++ b/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx @@ -66,24 +66,24 @@ bool checkRect(Bitmap& rBitmap, int aLayerNumber, long nAreaHeight, long nAreaWi for (long y = firstY; y <= lastY; y++) { - Color aColorFirst = pAccess->GetPixel(y, firstX); + Color aColorFirst = pAccess->GetPixel(y, firstX).GetColor(); delta = deltaColor(aColorFirst, aExpectedColor); if (delta > nMaxDelta) return false; - Color aColorLast = pAccess->GetPixel(y, lastX); + Color aColorLast = pAccess->GetPixel(y, lastX).GetColor(); delta = deltaColor(aColorLast, aExpectedColor); if (delta > nMaxDelta) return false; } for (long x = firstX; x <= lastX; x++) { - Color aColorFirst = pAccess->GetPixel(firstY, x); + Color aColorFirst = pAccess->GetPixel(firstY, x).GetColor(); delta = deltaColor(aColorFirst, aExpectedColor); if (delta > nMaxDelta) return false; - Color aColorLast = pAccess->GetPixel(lastY, x); + Color aColorLast = pAccess->GetPixel(lastY, x).GetColor(); delta = deltaColor(aColorLast, aExpectedColor); if (delta > nMaxDelta) return false; diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx index 1e6508789574..c2004f6ef012 100644 --- a/vcl/qa/cppunit/outdev.cxx +++ b/vcl/qa/cppunit/outdev.cxx @@ -56,21 +56,21 @@ void VclOutdevTest::testVirtualDevice() } #endif - CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(0,0)).GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(COL_WHITE), pVDev->GetPixel(Point(0,0))); #if defined LINUX //TODO: various failures on Mac and Windows tinderboxes - CPPUNIT_ASSERT_EQUAL(COL_BLUE, pVDev->GetPixel(Point(1,2)).GetColor()); - CPPUNIT_ASSERT_EQUAL(COL_RED, pVDev->GetPixel(Point(31,30)).GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(COL_BLUE), pVDev->GetPixel(Point(1,2))); + CPPUNIT_ASSERT_EQUAL(Color(COL_RED), pVDev->GetPixel(Point(31,30))); #endif - CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(30,31)).GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(COL_WHITE), pVDev->GetPixel(Point(30,31))); // Gotcha: y and x swap for BitmapReadAccess: deep joy. Bitmap::ScopedReadAccess pAcc(aBmp); - CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(pAcc->GetPixel(0,0)).GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(COL_WHITE), pAcc->GetPixel(0,0).GetColor()); #if defined LINUX //TODO: various failures on Mac and Windows tinderboxes - CPPUNIT_ASSERT_EQUAL(COL_BLUE, Color(pAcc->GetPixel(2,1)).GetColor()); - CPPUNIT_ASSERT_EQUAL(COL_RED, Color(pAcc->GetPixel(30,31)).GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(COL_BLUE), pAcc->GetPixel(2,1).GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(COL_RED), pAcc->GetPixel(30,31).GetColor()); #endif - CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(pAcc->GetPixel(31,30)).GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(COL_WHITE), pAcc->GetPixel(31,30).GetColor()); #if 0 VclPtr<vcl::Window> pWin = VclPtr<WorkWindow>::Create( (vcl::Window *)nullptr ); diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx index 2e69610e2d0c..28365159afa7 100644 --- a/vcl/quartz/salbmp.cxx +++ b/vcl/quartz/salbmp.cxx @@ -465,7 +465,7 @@ public: } virtual ColorData ReadPixel() override { - return mrPalette[ *pData++ ].operator Color().GetColor(); + return mrPalette[ *pData++ ].GetColor().GetColor(); } virtual void WritePixel( ColorData nColor ) override { @@ -511,7 +511,7 @@ public: const BitmapColor& rColor = mrPalette[( pData[mnX >> 1] >> mnShift) & 0x0f]; mnX++; mnShift ^= 4; - return rColor.operator Color().GetColor(); + return rColor.GetColor().GetColor(); } virtual void WritePixel( ColorData nColor ) override { @@ -552,7 +552,7 @@ public: { const BitmapColor& rColor = mrPalette[ (pData[mnX >> 3 ] >> ( 7 - ( mnX & 7 ) )) & 1]; mnX++; - return rColor.operator Color().GetColor(); + return rColor.GetColor().GetColor(); } virtual void WritePixel( ColorData nColor ) override { diff --git a/vcl/source/bitmap/BitmapProcessor.cxx b/vcl/source/bitmap/BitmapProcessor.cxx index 52d5b6e779d7..590af367a6d6 100644 --- a/vcl/source/bitmap/BitmapProcessor.cxx +++ b/vcl/source/bitmap/BitmapProcessor.cxx @@ -29,24 +29,28 @@ BitmapEx BitmapProcessor::createLightImage(const BitmapEx& rBitmapEx) { for (long nX = 0; nX < aSize.Width(); ++nX) { - BitmapColor aColor = pRead->HasPalette() ? + BitmapColor aBmpColor = pRead->HasPalette() ? pRead->GetPaletteColor(pRead->GetPixelIndex(nY, nX)) : pRead->GetPixel(nY, nX); - basegfx::BColor aBColor(Color(aColor.Invert()).getBColor()); + basegfx::BColor aBColor(Color(aBmpColor.Invert().GetColor()).getBColor()); aBColor = basegfx::utils::rgb2hsl(aBColor); double fHue = aBColor.getRed(); fHue += 180.0; + while (fHue > 360.0) + { fHue -= 360.0; + } + aBColor.setRed(fHue); aBColor = basegfx::utils::hsl2rgb(aBColor); - aColor.SetRed((aBColor.getRed() * 255.0) + 0.5); - aColor.SetGreen((aBColor.getGreen() * 255.0) + 0.5); - aColor.SetBlue((aBColor.getBlue() * 255.0) + 0.5); + aBmpColor.SetRed((aBColor.getRed() * 255.0) + 0.5); + aBmpColor.SetGreen((aBColor.getGreen() * 255.0) + 0.5); + aBmpColor.SetBlue((aBColor.getBlue() * 255.0) + 0.5); - pWrite->SetPixel(nY, nX, aColor); + pWrite->SetPixel(nY, nX, aBmpColor); } } } diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index 30cb0c674813..f24414f7e634 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -156,10 +156,10 @@ void GIFReader::ClearImageExtensions() nTimer = 0; } -void GIFReader::CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal, - bool bWatchForBackgroundColor ) +void GIFReader::CreateBitmaps(long nWidth, long nHeight, BitmapPalette* pPal, + bool bWatchForBackgroundColor) { - const Size aSize( nWidth, nHeight ); + const Size aSize(nWidth, nHeight); sal_uInt64 nCombinedPixSize = nWidth * nHeight; if (bGCTransparent) @@ -171,6 +171,7 @@ void GIFReader::CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal, // 1:1472.88 [184.11 x 8] is more realistic) sal_uInt64 nMinFileData = nWidth * nHeight / 2560; + nMinFileData += nAnimationMinFileData; nCombinedPixSize += nAnimationByteSize; @@ -195,34 +196,36 @@ void GIFReader::CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal, return; } - if( bGCTransparent ) + if (bGCTransparent) { - const Color aWhite( COL_WHITE ); + const Color aWhite(COL_WHITE); - aBmp1 = Bitmap( aSize, 1 ); + aBmp1 = Bitmap(aSize, 1); - if( !aAnimation.Count() ) - aBmp1.Erase( aWhite ); + if (!aAnimation.Count()) + aBmp1.Erase(aWhite); pAcc1 = Bitmap::ScopedWriteAccess(aBmp1); - if( pAcc1 ) + if (pAcc1) { - cTransIndex1 = static_cast<sal_uInt8>(pAcc1->GetBestPaletteIndex( aWhite )); + cTransIndex1 = static_cast<sal_uInt8>(pAcc1->GetBestPaletteIndex(aWhite)); cNonTransIndex1 = cTransIndex1 ? 0 : 1; } else + { bStatus = false; + } } - if( bStatus ) + if (bStatus) { - aBmp8 = Bitmap( aSize, 8, pPal ); + aBmp8 = Bitmap(aSize, 8, pPal); - if( !!aBmp8 && bWatchForBackgroundColor && aAnimation.Count() ) - aBmp8.Erase( (*pPal)[ nBackgroundColor ] ); + if (!!aBmp8 && bWatchForBackgroundColor && aAnimation.Count()) + aBmp8.Erase((*pPal)[nBackgroundColor].GetColor()); else - aBmp8.Erase( Color( COL_WHITE ) ); + aBmp8.Erase(Color(COL_WHITE)); pAcc8 = Bitmap::ScopedWriteAccess(aBmp8); bStatus = bool(pAcc8); diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 63029ce65cf3..e9f7eee83cbd 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -330,12 +330,12 @@ bool BitmapEx::Invert() { bool bRet = false; - if( !!aBitmap ) + if (!!aBitmap) { bRet = aBitmap.Invert(); - if( bRet && ( eTransparent == TransparentType::Color ) ) - aTransparentColor = BitmapColor( aTransparentColor ).Invert(); + if (bRet && (eTransparent == TransparentType::Color)) + aTransparentColor = BitmapColor(aTransparentColor).Invert().GetColor(); } return bRet; @@ -726,13 +726,12 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const if(pRead) { - const Color aColor = pRead->GetColor(nY, nX); + const BitmapColor aBmpColor = pRead->GetColor(nY, nX); + const Color aColor = aBmpColor.GetColor(); // If color is not equal to TransparentColor, we are not transparent - if(aColor != aTransparentColor) - { + if (aColor != aTransparentColor) nTransparency = 0x00; - } } break; diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx index e954a50780ce..9bb759400c97 100644 --- a/vcl/source/gdi/pngread.cxx +++ b/vcl/source/gdi/pngread.cxx @@ -842,44 +842,47 @@ void PNGReaderImpl::ImplGetGamma() void PNGReaderImpl::ImplGetBackground() { - switch ( mnColorType ) + switch (mnColorType) { - case 3 : + case 3: { - if ( mnChunkLen == 1 ) + if (mnChunkLen == 1) { sal_uInt16 nCol = *maDataIter++; - if ( nCol < mxAcc->GetPaletteEntryCount() ) + + if (nCol < mxAcc->GetPaletteEntryCount()) { - mxAcc->Erase( mxAcc->GetPaletteColor( static_cast<sal_uInt8>(nCol) ) ); + BitmapColor aBmpColor = mxAcc->GetPaletteColor(static_cast<sal_uInt8>(nCol)); + mxAcc->Erase(aBmpColor.GetColor()); break; } } } break; - case 0 : - case 4 : + case 0: + case 4: { - if ( mnChunkLen == 2 ) + if (mnChunkLen == 2) { // the color type 0 and 4 is always greyscale, // so the return value can be used as index sal_uInt8 nIndex = ImplScaleColor(); - mxAcc->Erase( mxAcc->GetPaletteColor( nIndex ) ); + BitmapColor aBmpColor = mxAcc->GetPaletteColor(nIndex); + mxAcc->Erase(aBmpColor.GetColor()); } } break; - case 2 : - case 6 : + case 2: + case 6: { - if ( mnChunkLen == 6 ) + if (mnChunkLen == 6) { sal_uInt8 nRed = ImplScaleColor(); sal_uInt8 nGreen = ImplScaleColor(); sal_uInt8 nBlue = ImplScaleColor(); - mxAcc->Erase( Color( nRed, nGreen, nBlue ) ); + mxAcc->Erase(Color(nRed, nGreen, nBlue)); } } break; diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index 57f0d4e0e4f3..4334eb0e7e81 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -150,44 +150,44 @@ bool checkRect( tools::Rectangle& io_rPrevRect, Add converted actions to this metafile */ void ImplConvertTransparentAction( GDIMetaFile& o_rMtf, - const MetaAction& rAct, - const OutputDevice& rStateOutDev, - Color aBgColor ) + const MetaAction& rAct, + const OutputDevice& rStateOutDev, + Color aBgColor ) { - if( rAct.GetType() == MetaActionType::Transparent ) + if (rAct.GetType() == MetaActionType::Transparent) { const MetaTransparentAction* pTransAct = static_cast<const MetaTransparentAction*>(&rAct); - sal_uInt16 nTransparency( pTransAct->GetTransparence() ); + sal_uInt16 nTransparency( pTransAct->GetTransparence() ); // #i10613# Respect transparency for draw color - if( nTransparency ) + if (nTransparency) { - o_rMtf.AddAction( new MetaPushAction( PushFlags::LINECOLOR|PushFlags::FILLCOLOR ) ); + o_rMtf.AddAction(new MetaPushAction(PushFlags::LINECOLOR|PushFlags::FILLCOLOR)); // assume white background for alpha blending - Color aLineColor( rStateOutDev.GetLineColor() ); - aLineColor.SetRed( static_cast<sal_uInt8>( (255*nTransparency + (100 - nTransparency)*aLineColor.GetRed()) / 100 ) ); - aLineColor.SetGreen( static_cast<sal_uInt8>( (255*nTransparency + (100 - nTransparency)*aLineColor.GetGreen()) / 100 ) ); - aLineColor.SetBlue( static_cast<sal_uInt8>( (255*nTransparency + (100 - nTransparency)*aLineColor.GetBlue()) / 100 ) ); - o_rMtf.AddAction( new MetaLineColorAction(aLineColor, true) ); - - Color aFillColor( rStateOutDev.GetFillColor() ); - aFillColor.SetRed( static_cast<sal_uInt8>( (255*nTransparency + (100 - nTransparency)*aFillColor.GetRed()) / 100 ) ); - aFillColor.SetGreen( static_cast<sal_uInt8>( (255*nTransparency + (100 - nTransparency)*aFillColor.GetGreen()) / 100 ) ); - aFillColor.SetBlue( static_cast<sal_uInt8>( (255*nTransparency + (100 - nTransparency)*aFillColor.GetBlue()) / 100 ) ); - o_rMtf.AddAction( new MetaFillColorAction(aFillColor, true) ); + Color aLineColor(rStateOutDev.GetLineColor()); + aLineColor.SetRed(static_cast<sal_uInt8>((255*nTransparency + (100 - nTransparency) * aLineColor.GetRed()) / 100)); + aLineColor.SetGreen(static_cast<sal_uInt8>((255*nTransparency + (100 - nTransparency) * aLineColor.GetGreen()) / 100)); + aLineColor.SetBlue(static_cast<sal_uInt8>((255*nTransparency + (100 - nTransparency) * aLineColor.GetBlue()) / 100)); + o_rMtf.AddAction(new MetaLineColorAction(aLineColor, true)); + + Color aFillColor(rStateOutDev.GetFillColor()); + aFillColor.SetRed(static_cast<sal_uInt8>((255*nTransparency + (100 - nTransparency)*aFillColor.GetRed()) / 100)); + aFillColor.SetGreen(static_cast<sal_uInt8>((255*nTransparency + (100 - nTransparency)*aFillColor.GetGreen()) / 100)); + aFillColor.SetBlue(static_cast<sal_uInt8>((255*nTransparency + (100 - nTransparency)*aFillColor.GetBlue()) / 100)); + o_rMtf.AddAction(new MetaFillColorAction(aFillColor, true)); } - o_rMtf.AddAction( new MetaPolyPolygonAction(pTransAct->GetPolyPolygon()) ); + o_rMtf.AddAction(new MetaPolyPolygonAction(pTransAct->GetPolyPolygon())); - if( nTransparency ) - o_rMtf.AddAction( new MetaPopAction() ); + if(nTransparency) + o_rMtf.AddAction(new MetaPopAction()); } else { BitmapEx aBmpEx; - switch( rAct.GetType() ) + switch (rAct.GetType()) { case MetaActionType::BMPEX: aBmpEx = static_cast<const MetaBmpExAction&>(rAct).GetBitmapEx(); @@ -208,65 +208,65 @@ void ImplConvertTransparentAction( GDIMetaFile& o_rMtf, break; } - Bitmap aBmp( aBmpEx.GetBitmap() ); - if( !aBmpEx.IsAlpha() ) + Bitmap aBmp(aBmpEx.GetBitmap()); + if (!aBmpEx.IsAlpha()) { // blend with mask Bitmap::ScopedReadAccess pRA(aBmp); - if( !pRA ) + if (!pRA) return; // what else should I do? - Color aActualColor( aBgColor ); + Color aActualColor(aBgColor); - if( pRA->HasPalette() ) - aActualColor = pRA->GetBestPaletteColor( aBgColor ).operator Color(); + if (pRA->HasPalette()) + aActualColor = pRA->GetBestPaletteColor(aBgColor).GetColor(); pRA.reset(); // did we get true white? - if( aActualColor.GetColorError( aBgColor ) ) + if (aActualColor.GetColorError(aBgColor)) { // no, create truecolor bitmap, then - aBmp.Convert( BmpConversion::N24Bit ); + aBmp.Convert(BmpConversion::N24Bit); // fill masked out areas white - aBmp.Replace( aBmpEx.GetMask(), aBgColor ); + aBmp.Replace(aBmpEx.GetMask(), aBgColor); } else { // fill masked out areas white - aBmp.Replace( aBmpEx.GetMask(), aActualColor ); + aBmp.Replace(aBmpEx.GetMask(), aActualColor); } } else { // blend with alpha channel - aBmp.Convert( BmpConversion::N24Bit ); - aBmp.Blend(aBmpEx.GetAlpha(),aBgColor); + aBmp.Convert(BmpConversion::N24Bit); + aBmp.Blend(aBmpEx.GetAlpha(), aBgColor); } // add corresponding action - switch( rAct.GetType() ) + switch (rAct.GetType()) { case MetaActionType::BMPEX: - o_rMtf.AddAction( new MetaBmpAction( + o_rMtf.AddAction(new MetaBmpAction( static_cast<const MetaBmpExAction&>(rAct).GetPoint(), - aBmp )); + aBmp)); break; case MetaActionType::BMPEXSCALE: - o_rMtf.AddAction( new MetaBmpScaleAction( + o_rMtf.AddAction(new MetaBmpScaleAction( static_cast<const MetaBmpExScaleAction&>(rAct).GetPoint(), static_cast<const MetaBmpExScaleAction&>(rAct).GetSize(), - aBmp )); + aBmp)); break; case MetaActionType::BMPEXSCALEPART: - o_rMtf.AddAction( new MetaBmpScalePartAction( + o_rMtf.AddAction(new MetaBmpScalePartAction( static_cast<const MetaBmpExScalePartAction&>(rAct).GetDestPoint(), static_cast<const MetaBmpExScalePartAction&>(rAct).GetDestSize(), static_cast<const MetaBmpExScalePartAction&>(rAct).GetSrcPoint(), static_cast<const MetaBmpExScalePartAction&>(rAct).GetSrcSize(), - aBmp )); + aBmp)); break; default: OSL_FAIL("Unexpected case"); diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx index a9b3cfe3945f..342edf526e57 100644 --- a/vcl/unx/generic/gdi/gdiimpl.cxx +++ b/vcl/unx/generic/gdi/gdiimpl.cxx @@ -110,10 +110,10 @@ namespace if (rPalette.GetEntryCount() == 2) { const BitmapColor aWhite(rPalette[rPalette.GetBestIndex(Color(COL_WHITE))]); - rValues.foreground = rColMap.GetPixel(ImplColorToSal(aWhite)); + rValues.foreground = rColMap.GetPixel(ImplColorToSal(aWhite.GetColor())); const BitmapColor aBlack(rPalette[rPalette.GetBestIndex(Color(COL_BLACK))]); - rValues.background = rColMap.GetPixel(ImplColorToSal(aBlack)); + rValues.background = rColMap.GetPixel(ImplColorToSal(aBlack.GetColor())); } rBitmap.ReleaseBuffer(pBitmapBuffer, BitmapAccessMode::Read); } diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index cce4729b8742..e3dfddf10302 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -625,9 +625,9 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, const WinSalBitmap& rSa if (rPalette.GetEntryCount() == 2) { SalColor nCol; - nCol = ImplColorToSal(rPalette[0]); + nCol = ImplColorToSal(rPalette[0].GetColor()); nTextColor = RGB( SALCOLOR_RED(nCol), SALCOLOR_GREEN(nCol), SALCOLOR_BLUE(nCol) ); - nCol = ImplColorToSal(rPalette[1]); + nCol = ImplColorToSal(rPalette[1].GetColor()); nBkColor = RGB( SALCOLOR_RED(nCol), SALCOLOR_GREEN(nCol), SALCOLOR_BLUE(nCol) ); } const_cast<WinSalBitmap&>(rSalBitmap).ReleaseBuffer(pBitmapBuffer, BitmapAccessMode::Info); |