diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-05-11 11:49:21 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-05-13 15:43:17 +0200 |
commit | c34bb163c38cfa893d1b5b0124ab9c5929dff16c (patch) | |
tree | 8994582e896495c8fe919e7a26c2852f9d120ec2 /vcl/source | |
parent | 0725e8a5d9add88b1289f5b1cb90b0b43059a734 (diff) |
Make BitmapColor inherit from / merge into Color
BitmapColor itself is kept to distingish the Color usage as part
of a color palette, which continues to store the offset in the
blue value. The original special mbIndex handling is long gone
since commit 1fefdd6f3b41 ("Alpha channel in BitmapColor - change
bIndex to alpha"), so there is no data difference.
This also results in the following changes:
* now has a basic_ostream<charT, traits>& operator<<
(that was my actual starting point... for an other bug fix)
* there is a minimal difference for GetLiminance
BGR(29,151,76) => BGR(28,151,77)
* no more return values for Merge and Invert
(previously returning *this)
* replaces all GetBlueOrIndex with GetIndex
This leaves one "problematic" part: the GetColorError handling.
At first glance it should probably be virtual. The Color variant
is less strict then the BitmapColor one - for whatever reason.
BitmapColor is always used to search for the best match in a
Palette. Currently I'm simply leaving both variants. Would be
nice to have an explict for functions here.
Change-Id: I251ba3024a1d60f2a9d9fde9cd0a60f08e8322a7
Reviewed-on: https://gerrit.libreoffice.org/72181
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/bitmap/BitmapLightenFilter.cxx | 3 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapSolarizeFilter.cxx | 8 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapTools.cxx | 10 | ||||
-rw-r--r-- | vcl/source/bitmap/bitmappaint.cxx | 19 | ||||
-rw-r--r-- | vcl/source/control/combobox.cxx | 2 | ||||
-rw-r--r-- | vcl/source/control/imp_listbox.cxx | 2 | ||||
-rw-r--r-- | vcl/source/filter/igif/gifread.cxx | 2 | ||||
-rw-r--r-- | vcl/source/filter/png/pngread.cxx | 7 | ||||
-rw-r--r-- | vcl/source/gdi/bitmapex.cxx | 9 | ||||
-rw-r--r-- | vcl/source/gdi/bmpacc2.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/print2.cxx | 2 | ||||
-rw-r--r-- | vcl/source/graphic/UnoGraphicTransformer.cxx | 6 | ||||
-rw-r--r-- | vcl/source/outdev/bitmap.cxx | 8 | ||||
-rw-r--r-- | vcl/source/outdev/transparent.cxx | 6 |
14 files changed, 44 insertions, 42 deletions
diff --git a/vcl/source/bitmap/BitmapLightenFilter.cxx b/vcl/source/bitmap/BitmapLightenFilter.cxx index 52e41ae33e97..45013b143783 100644 --- a/vcl/source/bitmap/BitmapLightenFilter.cxx +++ b/vcl/source/bitmap/BitmapLightenFilter.cxx @@ -37,7 +37,8 @@ BitmapEx BitmapLightenFilter::execute(BitmapEx const& rBitmapEx) const = pRead->HasPalette() ? pRead->GetPaletteColor(pRead->GetIndexFromData(pScanlineRead, nX)) : pRead->GetPixelFromData(pScanlineRead, nX); - basegfx::BColor aBColor(aBmpColor.Invert().GetColor().getBColor()); + aBmpColor.Invert(); + basegfx::BColor aBColor(aBmpColor.getBColor()); aBColor = basegfx::utils::rgb2hsl(aBColor); double fHue = aBColor.getRed(); diff --git a/vcl/source/bitmap/BitmapSolarizeFilter.cxx b/vcl/source/bitmap/BitmapSolarizeFilter.cxx index d12986c81c9f..179868aa5e2d 100644 --- a/vcl/source/bitmap/BitmapSolarizeFilter.cxx +++ b/vcl/source/bitmap/BitmapSolarizeFilter.cxx @@ -32,7 +32,8 @@ BitmapEx BitmapSolarizeFilter::execute(BitmapEx const& rBitmapEx) const if (rPal[i].GetLuminance() >= mcSolarGreyThreshold) { BitmapColor aCol(rPal[i]); - pWriteAcc->SetPaletteColor(i, aCol.Invert()); + aCol.Invert(); + pWriteAcc->SetPaletteColor(i, aCol); } } } @@ -50,7 +51,10 @@ BitmapEx BitmapSolarizeFilter::execute(BitmapEx const& rBitmapEx) const aCol = pWriteAcc->GetPixelFromData(pScanline, nX); if (aCol.GetLuminance() >= mcSolarGreyThreshold) - pWriteAcc->SetPixelOnData(pScanline, nX, aCol.Invert()); + { + aCol.Invert(); + pWriteAcc->SetPixelOnData(pScanline, nX, aCol); + } } } } diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index 380d46a7f7f7..531a49bc9cc5 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -675,7 +675,7 @@ static bool readAlpha( BitmapReadAccess const * pAlphaReadAcc, long nY, const lo BitmapColor const& rColor( pAlphaReadAcc->GetPaletteColor(*pReadScan)); pReadScan++; - nAlpha = data[ nOff ] = 255 - rColor.GetBlueOrIndex(); + nAlpha = data[ nOff ] = 255 - rColor.GetIndex(); if( nAlpha != 255 ) bIsAlpha = true; nOff += 4; @@ -747,7 +747,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un else nAlpha = data[ nOff + 3 ] = 255; #endif - aColor = pBitmapReadAcc->GetPaletteColor(*pReadScan++).GetColor(); + aColor = pBitmapReadAcc->GetPaletteColor(*pReadScan++); #ifdef OSL_BIGENDIAN data[ nOff++ ] = premultiply_table[nAlpha][aColor.GetRed()]; @@ -888,7 +888,7 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un for( nX = 0; nX < nWidth; nX++ ) { - aColor = pBitmapReadAcc->GetColor( nY, nX ).GetColor(); + aColor = pBitmapReadAcc->GetColor( nY, nX ); // cairo need premultiplied color values // TODO(rodo) handle endianness @@ -1025,8 +1025,8 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un // #i123564# background and foreground were exchanged; of course // rPalette[0] is the background color - o_rFront = rPalette[1].GetColor(); - o_rBack = rPalette[0].GetColor(); + o_rFront = rPalette[1]; + o_rBack = rPalette[0]; bRet = true; } diff --git a/vcl/source/bitmap/bitmappaint.cxx b/vcl/source/bitmap/bitmappaint.cxx index 02df3c8a6b29..04b301d47d89 100644 --- a/vcl/source/bitmap/bitmappaint.cxx +++ b/vcl/source/bitmap/bitmappaint.cxx @@ -140,8 +140,9 @@ bool Bitmap::Invert() Scanline pScanline = pAcc->GetScanline(nY); for (long nX = 0; nX < nWidth; nX++) { - pAcc->SetPixelOnData(pScanline, nX, - pAcc->GetPixelFromData(pScanline, nX).Invert()); + BitmapColor aBmpColor = pAcc->GetPixelFromData(pScanline, nX); + aBmpColor.Invert(); + pAcc->SetPixelOnData(pScanline, nX, aBmpColor); } } } @@ -830,9 +831,8 @@ bool Bitmap::Replace(const AlphaMask& rAlpha, const Color& rMergeColor) for (long nX = 0; nX < nWidth; nX++) { aCol = pAcc->GetColor(nY, nX); - pNewAcc->SetPixelOnData( - pScanline, nX, - aCol.Merge(rMergeColor, 255 - pAlphaAcc->GetIndexFromData(pScanlineAlpha, nX))); + aCol.Merge(rMergeColor, 255 - pAlphaAcc->GetIndexFromData(pScanlineAlpha, nX)); + pNewAcc->SetPixelOnData(pScanline, nX, aCol); } } @@ -1132,11 +1132,10 @@ bool Bitmap::Blend(const AlphaMask& rAlpha, const Color& rBackgroundColor) Scanline pScanlineAlpha = pAlphaAcc->GetScanline(nY); for (long nX = 0; nX < nWidth; ++nX) { - pAcc->SetPixelOnData( - pScanline, nX, - pAcc->GetPixelFromData(pScanline, nX) - .Merge(rBackgroundColor, - 255 - pAlphaAcc->GetIndexFromData(pScanlineAlpha, nX))); + BitmapColor aBmpColor = pAcc->GetPixelFromData(pScanline, nX); + aBmpColor.Merge(rBackgroundColor, + 255 - pAlphaAcc->GetIndexFromData(pScanlineAlpha, nX)); + pAcc->SetPixelOnData(pScanline, nX, aBmpColor); } } diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index ddb644658a12..109c8374243b 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -1367,7 +1367,7 @@ const Wallpaper& ComboBox::GetDisplayBackground() const const Wallpaper& rBack = m_pImpl->m_pSubEdit->GetBackground(); if( ! rBack.IsBitmap() && ! rBack.IsGradient() && - rBack.GetColor() == COL_TRANSPARENT + rBack == COL_TRANSPARENT ) return Control::GetDisplayBackground(); return rBack; diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index e2a78a1383f0..e7e2344f5096 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -1867,7 +1867,7 @@ void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32 if ( !maSeparators.empty() && ( isSeparator(nPos) || isSeparator(nPos-1) ) ) { Color aOldLineColor(rRenderContext.GetLineColor()); - rRenderContext.SetLineColor((GetBackground().GetColor() != COL_LIGHTGRAY) ? COL_LIGHTGRAY : COL_GRAY); + rRenderContext.SetLineColor((GetBackground() != COL_LIGHTGRAY) ? COL_LIGHTGRAY : COL_GRAY); Point aStartPos(0, nY); if (isSeparator(nPos)) aStartPos.AdjustY(pEntry->getHeightWithMargin() - 1 ); diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index 6378e63ab021..759e572fbbd3 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -232,7 +232,7 @@ void GIFReader::CreateBitmaps(long nWidth, long nHeight, BitmapPalette* pPal, aBmp8 = Bitmap(aSize, 8, pPal); if (!!aBmp8 && bWatchForBackgroundColor && aAnimation.Count()) - aBmp8.Erase((*pPal)[nBackgroundColor].GetColor()); + aBmp8.Erase((*pPal)[nBackgroundColor]); else aBmp8.Erase(COL_WHITE); diff --git a/vcl/source/filter/png/pngread.cxx b/vcl/source/filter/png/pngread.cxx index 58acc12c8d60..4107325bf7a9 100644 --- a/vcl/source/filter/png/pngread.cxx +++ b/vcl/source/filter/png/pngread.cxx @@ -843,8 +843,7 @@ void PNGReaderImpl::ImplGetBackground() if (nCol < mxAcc->GetPaletteEntryCount()) { - BitmapColor aBmpColor = mxAcc->GetPaletteColor(static_cast<sal_uInt8>(nCol)); - mxAcc->Erase(aBmpColor.GetColor()); + mxAcc->Erase(mxAcc->GetPaletteColor(static_cast<sal_uInt8>(nCol))); break; } } @@ -858,9 +857,7 @@ void PNGReaderImpl::ImplGetBackground() { // the color type 0 and 4 is always greyscale, // so the return value can be used as index - sal_uInt8 nIndex = ImplScaleColor(); - BitmapColor aBmpColor = mxAcc->GetPaletteColor(nIndex); - mxAcc->Erase(aBmpColor.GetColor()); + mxAcc->Erase(mxAcc->GetPaletteColor(ImplScaleColor())); } } break; diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index e5aea9401e9f..2ea870e341e6 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -324,7 +324,7 @@ bool BitmapEx::Invert() bRet = maBitmap.Invert(); if (bRet && (meTransparent == TransparentType::Color)) - maTransparentColor = BitmapColor(maTransparentColor).Invert().GetColor(); + maTransparentColor.Invert(); } return bRet; @@ -705,10 +705,9 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const if(pRead) { 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 != maTransparentColor) + if (aBmpColor != maTransparentColor) nTransparency = 0x00; } @@ -753,7 +752,7 @@ Color BitmapEx::GetPixelColor(sal_Int32 nX, sal_Int32 nY) const Bitmap::ScopedReadAccess pReadAccess( const_cast<Bitmap&>(maBitmap) ); assert(pReadAccess); - Color aColor = pReadAccess->GetColor(nY, nX).GetColor(); + BitmapColor aColor = pReadAccess->GetColor(nY, nX); if (IsAlpha()) { @@ -1310,7 +1309,7 @@ void BitmapEx::setAlphaFrom( sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo ) Scanline pScanlineRead = pReadAccess->GetScanline( nY ); for ( long nX = 0; nX < pReadAccess->Width(); nX++ ) { - const sal_uInt8 cIndex = pReadAccess->GetPixelFromData( pScanlineRead, nX ).GetBlueOrIndex(); + const sal_uInt8 cIndex = pReadAccess->GetPixelFromData( pScanlineRead, nX ).GetIndex(); if ( cIndex == cIndexFrom ) pWriteAccess->SetPixelOnData( pScanline, nX, BitmapColor(nAlphaTo) ); } diff --git a/vcl/source/gdi/bmpacc2.cxx b/vcl/source/gdi/bmpacc2.cxx index 4ac7b84c3e7c..0c382d08db91 100644 --- a/vcl/source/gdi/bmpacc2.cxx +++ b/vcl/source/gdi/bmpacc2.cxx @@ -99,7 +99,7 @@ BitmapColor BitmapReadAccess::GetPixelForN8BitPal(ConstScanline pScanline, long void BitmapReadAccess::SetPixelForN8BitPal(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&) { - pScanline[ nX ] = rBitmapColor.GetBlueOrIndex(); + pScanline[ nX ] = rBitmapColor.GetIndex(); } BitmapColor BitmapReadAccess::GetPixelForN8BitTcMask(ConstScanline pScanline, long nX, const ColorMask& rMask) diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index 3ec7bbf494db..1ca7014778f5 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -221,7 +221,7 @@ void ImplConvertTransparentAction( GDIMetaFile& o_rMtf, Color aActualColor(aBgColor); if (pRA->HasPalette()) - aActualColor = pRA->GetBestPaletteColor(aBgColor).GetColor(); + aActualColor = pRA->GetBestPaletteColor(aBgColor); pRA.reset(); diff --git a/vcl/source/graphic/UnoGraphicTransformer.cxx b/vcl/source/graphic/UnoGraphicTransformer.cxx index f50101fff6f4..13e1adbee114 100644 --- a/vcl/source/graphic/UnoGraphicTransformer.cxx +++ b/vcl/source/graphic/UnoGraphicTransformer.cxx @@ -56,10 +56,10 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange( 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()); + Color aColorFrom(aBmpColorFrom); + Color aColorTo(aBmpColorTo); - const sal_uInt8 cIndexFrom = aBmpColorFrom.GetBlueOrIndex(); + const sal_uInt8 cIndexFrom = aBmpColorFrom.GetIndex(); if (aGraphic.GetType() == GraphicType::Bitmap || aGraphic.GetType() == GraphicType::GdiMetafile) diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 0e57b2a9f203..5322a0a29cea 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -1580,8 +1580,8 @@ Bitmap OutputDevice::BlendBitmap( nMapX = aBmpRect.Right() - nMapX; } aDstCol = pB->GetPixelFromData( pBScan, nX ); - pB->SetPixelOnData( pBScan, nX, aDstCol.Merge( pP->GetPaletteColor( pPScan[ nMapX ] ), - pAScan[ nMapX ] ) ); + aDstCol.Merge( pP->GetPaletteColor( pPScan[ nMapX ] ), pAScan[ nMapX ] ); + pB->SetPixelOnData( pBScan, nX, aDstCol ); } } } @@ -1609,8 +1609,8 @@ Bitmap OutputDevice::BlendBitmap( nMapX = aBmpRect.Right() - nMapX; } aDstCol = pB->GetPixelFromData( pBScan, nX ); - pB->SetPixelOnData( pBScan, nX, aDstCol.Merge( pP->GetColor( nMapY, nMapX ), - pAScan[ nMapX ] ) ); + aDstCol.Merge( pP->GetColor( nMapY, nMapX ), pAScan[ nMapX ] ); + pB->SetPixelOnData( pBScan, nX, aDstCol ); } } } diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index 205de6baaec1..a2fbbf6c6ac2 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -523,7 +523,8 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, for( sal_uInt16 i = 0; i < nCount; i++ ) { BitmapColor aCol( rPal[ i ] ); - pMap[ i ] = BitmapColor( static_cast<sal_uInt8>(rPal.GetBestIndex( aCol.Merge( aFillCol, cTrans ) )) ); + aCol.Merge( aFillCol, cTrans ); + pMap[ i ] = BitmapColor( static_cast<sal_uInt8>(rPal.GetBestIndex( aCol )) ); } if( pR->GetScanlineFormat() == ScanlineFormat::N1BitMsbPal && @@ -608,7 +609,8 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, if( pR->GetPixelFromData( pScanlineRead, nX ) == aBlack ) { aPixCol = pW->GetColor( nY, nX ); - pW->SetPixelOnData(pScanline, nX, aPixCol.Merge( aFillCol, cTrans ) ); + aPixCol.Merge(aFillCol, cTrans); + pW->SetPixelOnData(pScanline, nX, aPixCol); } } } |