Kaydet (Commit) 203e3099 authored tarafından Noel Grandin's avatar Noel Grandin

make Bitmap/BitmapEx constructors explicit

and add
BitmapEx::operator=(Bitmap const &)
Image::Image(Bitmap const &)
to lessen the fallout

Change-Id: Iff5fab88d167a7be739c370c9933d36c297bc61c
Reviewed-on: https://gerrit.libreoffice.org/54162Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst f4932d61
......@@ -912,7 +912,7 @@ namespace vclcanvas
beFast ? BmpScaleFlag::Default : BmpScaleFlag::BestQuality );
return uno::Reference< rendering::XBitmap >(
new CanvasBitmap( aBitmap, *mpDevice, mpOutDevProvider ) );
new CanvasBitmap( BitmapEx(aBitmap), *mpDevice, mpOutDevProvider ) );
}
uno::Sequence< sal_Int8 > CanvasHelper::getData( rendering::IntegerBitmapLayout& rLayout,
......
......@@ -2108,7 +2108,7 @@ namespace cppcanvas
std::shared_ptr<Action> pBmpAction(
internal::BitmapActionFactory::createBitmapAction(
pAct->GetBitmap(),
BitmapEx(pAct->GetBitmap()),
rStates.getState().mapModeTransform *
vcl::unotools::b2DPointFromPoint( pAct->GetPoint() ),
rCanvas,
......@@ -2131,7 +2131,7 @@ namespace cppcanvas
std::shared_ptr<Action> pBmpAction(
internal::BitmapActionFactory::createBitmapAction(
pAct->GetBitmap(),
BitmapEx(pAct->GetBitmap()),
rStates.getState().mapModeTransform *
vcl::unotools::b2DPointFromPoint( pAct->GetPoint() ),
rStates.getState().mapModeTransform *
......@@ -2163,7 +2163,7 @@ namespace cppcanvas
std::shared_ptr<Action> pBmpAction(
internal::BitmapActionFactory::createBitmapAction(
aBmp,
BitmapEx(aBmp),
rStates.getState().mapModeTransform *
vcl::unotools::b2DPointFromPoint( pAct->GetDestPoint() ),
rStates.getState().mapModeTransform *
......
......@@ -386,8 +386,8 @@ IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, Button*, void)
RepaintToBuffer();
// extract Bitmap
const Bitmap aTargetBitmap(
mpVirtualBufferDevice->GetBitmap(
const BitmapEx aTargetBitmap(
mpVirtualBufferDevice->GetBitmapEx(
Point(0, 0),
mpVirtualBufferDevice->GetOutputSizePixel()));
......
......@@ -297,7 +297,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, ValueSet*, void)
{
BitmapColor aBack;
BitmapColor aFront;
bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmap(), aBack, aFront));
bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmapEx(), aBack, aFront));
m_pLbColor->SetNoSelection();
m_pLbBackgroundColor->SetNoSelection();
......
......@@ -100,7 +100,8 @@ namespace drawinglayer
if(bDoSaveForVisualControl)
{
SvFileStream aNew("c:\\test_content.png", StreamMode::WRITE|StreamMode::TRUNC);
vcl::PNGWriter aPNGWriter(aContent);
BitmapEx aContentEx = BitmapEx(aContent);
vcl::PNGWriter aPNGWriter(aContentEx);
aPNGWriter.Write(aNew);
}
#endif
......@@ -130,7 +131,8 @@ namespace drawinglayer
if(bDoSaveForVisualControl)
{
SvFileStream aNew("c:\\test_alpha.png", StreamMode::WRITE|StreamMode::TRUNC);
vcl::PNGWriter aPNGWriter(aAlpha);
BitmapEx aAlphaEx = BitmapEx(aAlpha);
vcl::PNGWriter aPNGWriter(aAlphaEx);
aPNGWriter.Write(aNew);
}
#endif
......
......@@ -2001,7 +2001,7 @@ namespace wmfemfhelper
{
/** CHECKED, WORKS WELL */
const MetaBmpScaleAction* pA = static_cast<const MetaBmpScaleAction*>(pAction);
const Bitmap aBitmapEx(pA->GetBitmap());
const BitmapEx aBitmapEx(pA->GetBitmap());
createBitmapExPrimitive(aBitmapEx, pA->GetPoint(), pA->GetSize(), rTargetHolders.Current(), rPropertyHolders.Current());
......
......@@ -1756,7 +1756,7 @@ namespace emfio
else
{
SetRasterOp( WMFRasterOp::XorPen );
ImplDrawBitmap( aPos, aSize, aBitmap );
ImplDrawBitmap( aPos, aSize, BitmapEx(aBitmap) );
SetRasterOp( WMFRasterOp::CopyPen );
Bitmap aMask( aBitmap );
aMask.Invert();
......@@ -1800,7 +1800,7 @@ namespace emfio
BitmapEx aBmpEx( aBitmap, aMask );
ImplDrawBitmap( aPos, aSize, aBmpEx );
SetRasterOp( WMFRasterOp::XorPen );
ImplDrawBitmap( aPos, aSize, aBitmap );
ImplDrawBitmap( aPos, aSize, BitmapEx(aBitmap) );
if ( nOperation == 0xb )
{
SetRasterOp( WMFRasterOp::Not );
......@@ -1817,7 +1817,7 @@ namespace emfio
BitmapEx aBmpEx( aBitmap, aMask );
ImplDrawBitmap( aPos, aSize, aBmpEx );
SetRasterOp( WMFRasterOp::XorPen );
ImplDrawBitmap( aPos, aSize, aBitmap );
ImplDrawBitmap( aPos, aSize, BitmapEx(aBitmap) );
if ( nOperation == 0xd )
{
SetRasterOp( WMFRasterOp::Not );
......@@ -1829,7 +1829,7 @@ namespace emfio
case 0x9 :
{
SetRasterOp( WMFRasterOp::XorPen );
ImplDrawBitmap( aPos, aSize, aBitmap );
ImplDrawBitmap( aPos, aSize, BitmapEx(aBitmap) );
if ( nOperation == 0x9 )
{
SetRasterOp( WMFRasterOp::Not );
......@@ -1852,7 +1852,7 @@ namespace emfio
{
if ( nRasterOperation == 0x33 )
aBitmap.Invert();
ImplDrawBitmap( aPos, aSize, aBitmap );
ImplDrawBitmap( aPos, aSize, BitmapEx(aBitmap) );
}
break;
......
......@@ -1512,7 +1512,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf )
{
bFound = true;
const MetaBmpScaleAction* pBmpScaleAction = static_cast<const MetaBmpScaleAction*>(pSubstAct);
Impl_writeImage( pBmpScaleAction->GetBitmap(),
Impl_writeImage( BitmapEx(pBmpScaleAction->GetBitmap()),
pA->GetPoint(), pA->GetSize(),
Point(), pBmpScaleAction->GetBitmap().GetSizePixel(), clipRect, 1 == bMap );
}
......@@ -1613,7 +1613,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf )
{
const MetaBmpScaleAction* pA = static_cast<const MetaBmpScaleAction*>(pAction);
Impl_writeImage( pA->GetBitmap(),
Impl_writeImage( BitmapEx(pA->GetBitmap()),
pA->GetPoint(), pA->GetSize(),
Point(), pA->GetBitmap().GetSizePixel(), clipRect, 1 == bMap );
}
......@@ -1622,7 +1622,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf )
case MetaActionType::BMP:
{
const MetaBmpAction* pA = static_cast<const MetaBmpAction*>(pAction);
Impl_writeImage( pA->GetBitmap(),
Impl_writeImage( BitmapEx(pA->GetBitmap()),
pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmap().GetSizePixel()),
Point(), pA->GetBitmap().GetSizePixel(), clipRect, 1 ==bMap );
}
......@@ -1631,7 +1631,7 @@ void Writer::Impl_writeActions( const GDIMetaFile& rMtf )
case MetaActionType::BMPSCALEPART:
{
const MetaBmpScalePartAction* pA = static_cast<const MetaBmpScalePartAction*>(pAction);
Impl_writeImage( pA->GetBitmap(),
Impl_writeImage( BitmapEx(pA->GetBitmap()),
pA->GetDestPoint(), pA->GetDestSize(),
pA->GetSrcPoint(), pA->GetSrcSize(), clipRect, 1 == bMap );
}
......
......@@ -168,7 +168,7 @@ bool TIFFWriter::WriteTIFF( const Graphic& rGraphic, FilterConfigItem const * pF
{
Animation aAnimation = rGraphic.IsAnimated() ? rGraphic.GetAnimation() : Animation();
if (!rGraphic.IsAnimated())
aAnimation.Insert(AnimationBitmap(rGraphic.GetBitmap(), Point(), Size()));
aAnimation.Insert(AnimationBitmap(rGraphic.GetBitmapEx(), Point(), Size()));
for (size_t i = 0; i < aAnimation.Count(); ++i)
mnSumOfAllPictHeight += aAnimation.Get(i).aBmpEx.GetSizePixel().Height();
......
......@@ -3066,7 +3066,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
{
bFound = true;
const MetaBmpScaleAction* pBmpScaleAction = static_cast<const MetaBmpScaleAction*>(pSubstAct);
ImplWriteBmp( pBmpScaleAction->GetBitmap(),
ImplWriteBmp( BitmapEx(pBmpScaleAction->GetBitmap()),
pA->GetPoint(), pA->GetSize(),
Point(), pBmpScaleAction->GetBitmap().GetSizePixel() );
}
......@@ -3448,7 +3448,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
{
const MetaBmpAction* pA = static_cast<const MetaBmpAction*>(pAction);
ImplWriteBmp( pA->GetBitmap(),
ImplWriteBmp( BitmapEx(pA->GetBitmap()),
pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmap().GetSizePixel() ),
Point(), pA->GetBitmap().GetSizePixel() );
}
......@@ -3468,7 +3468,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
}
else
{
ImplWriteBmp( pA->GetBitmap(),
ImplWriteBmp( BitmapEx(pA->GetBitmap()),
pA->GetPoint(), pA->GetSize(),
Point(), pA->GetBitmap().GetSizePixel() );
}
......@@ -3482,7 +3482,7 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
{
const MetaBmpScalePartAction* pA = static_cast<const MetaBmpScalePartAction*>(pAction);
ImplWriteBmp( pA->GetBitmap(),
ImplWriteBmp( BitmapEx(pA->GetBitmap()),
pA->GetDestPoint(), pA->GetDestSize(),
pA->GetSrcPoint(), pA->GetSrcSize() );
}
......
......@@ -124,7 +124,7 @@ public:
Bitmap();
Bitmap( const Bitmap& rBitmap );
Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal = nullptr );
Bitmap( SalBitmap* pSalBitmap );
explicit Bitmap( SalBitmap* pSalBitmap );
virtual ~Bitmap();
Bitmap& operator=( const Bitmap& rBitmap );
......
......@@ -45,15 +45,16 @@ class SAL_WARN_UNUSED VCL_DLLPUBLIC BitmapEx
public:
BitmapEx();
BitmapEx( const OUString& rIconName );
explicit BitmapEx( const OUString& rIconName );
BitmapEx( const BitmapEx& rBitmapEx );
BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize );
BitmapEx( const Bitmap& rBmp );
explicit BitmapEx( const Bitmap& rBmp );
BitmapEx( const Bitmap& rBmp, const Bitmap& rMask );
BitmapEx( const Bitmap& rBmp, const AlphaMask& rAlphaMask );
BitmapEx( const Bitmap& rBmp, const Color& rTransparentColor );
BitmapEx& operator=( const BitmapEx& rBitmapEx );
BitmapEx& operator=( const Bitmap& rBitmap ) { return operator=(BitmapEx(rBitmap)); }
bool operator==( const BitmapEx& rBitmapEx ) const;
bool operator!=( const BitmapEx& rBitmapEx ) const { return !(*this==rBitmapEx); }
bool operator!() const { return !maBitmap; }
......
......@@ -56,6 +56,7 @@ class SAL_WARN_UNUSED VCL_DLLPUBLIC Image
public:
Image();
explicit Image( const BitmapEx& rBitmapEx );
explicit Image( const Bitmap& rBitmap ) : Image( BitmapEx(rBitmap) ) {}
explicit Image( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic );
explicit Image( const OUString &rPNGFileUrl );
......
......@@ -712,7 +712,7 @@ void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillDa
Bitmap aBitmap;
ReadDIB(aBitmap, aMemStrm, false);
XOBitmap aXOBitmap( aBitmap );
XOBitmap aXOBitmap(( BitmapEx(aBitmap) ));
aXOBitmap.Bitmap2Array();
if( aXOBitmap.GetBackgroundColor() == COL_BLACK )
::std::swap( aPattColor, aBackColor );
......
......@@ -376,7 +376,7 @@ bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor, const OUSt
PaintToDev( pVirtDev, m_pDoc, 1.0, m_aBlock );
pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel ) );
Bitmap aBmp = pVirtDev->GetBitmap( Point(), pVirtDev->GetOutputSize() );
BitmapEx aBmp = pVirtDev->GetBitmapEx( Point(), pVirtDev->GetOutputSize() );
bOK = SetBitmapEx( aBmp, rFlavor );
}
else if ( nFormat == SotClipboardFormatId::GDIMETAFILE )
......
......@@ -162,7 +162,7 @@ public:
std::shared_ptr<BitmapReplacement> PngCompression::Compress (const Bitmap& rBitmap) const
{
vcl::PNGWriter aWriter (rBitmap);
vcl::PNGWriter aWriter ((BitmapEx(rBitmap)));
SvMemoryStream aStream (32768, 32768);
aWriter.Write(aStream);
......
......@@ -183,7 +183,7 @@ Point InsertionIndicatorOverlay::PaintRepresentatives (
aPageOffset.AdjustY(gnShadowBorder );
// Paint the preview.
Bitmap aPreview (rRepresentatives[nIndex].maBitmap);
BitmapEx aPreview (rRepresentatives[nIndex].maBitmap);
aPreview.Scale(rPreviewSize, BmpScaleFlag::BestQuality);
rContent.DrawBitmapEx(aPageOffset, aPreview);
......
......@@ -908,7 +908,7 @@ BitmapEx SvxBmpMask::ImpReplaceTransparency( const BitmapEx& rBmpEx, const Color
{
Bitmap aBmp( rBmpEx.GetBitmap() );
aBmp.Replace( rBmpEx.GetMask(), rColor );
return aBmp;
return BitmapEx(aBmp);
}
else
return rBmpEx;
......
......@@ -224,7 +224,7 @@ bool XFillBitmapItem::operator==(const SfxPoolItem& rItem) const
bool XFillBitmapItem::isPattern() const
{
BitmapColor aBack, aFront;
return isHistorical8x8(GetGraphicObject().GetGraphic().GetBitmap(), aBack, aFront);
return isHistorical8x8(GetGraphicObject().GetGraphic().GetBitmapEx(), aBack, aFront);
}
sal_uInt16 XFillBitmapItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
......
......@@ -81,7 +81,7 @@ void ScreenshotTest::implSaveScreenshot(const Bitmap& rScreenshot, const OString
SvFileStream aNew(pngUrl, StreamMode::WRITE | StreamMode::TRUNC);
CPPUNIT_ASSERT_MESSAGE(OUStringToOString("Failed to open <" + pngUrl + ">: " + OUString::number(sal_uInt32(aNew.GetErrorCode())), RTL_TEXTENCODING_UTF8).getStr(), aNew.IsOpen());
vcl::PNGWriter aPNGWriter(rScreenshot);
vcl::PNGWriter aPNGWriter((BitmapEx(rScreenshot)));
aPNGWriter.Write(aNew);
}
......
......@@ -665,7 +665,7 @@ void CanvasBitmapTest::runTest()
}
}
rtl::Reference<VclCanvasBitmap> xBmp( new VclCanvasBitmap(aBitmap) );
rtl::Reference<VclCanvasBitmap> xBmp( new VclCanvasBitmap(BitmapEx(aBitmap)) );
checkCanvasBitmap( xBmp, "single bitmap", nDepth );
......
......@@ -176,7 +176,7 @@ BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHe
if (nBitCount == 32)
return BitmapEx(aBmp, *pAlphaMask);
else
return aBmp;
return BitmapEx(aBmp);
}
/** Copy block of image data into the bitmap.
......@@ -227,7 +227,7 @@ BitmapEx CreateFromData( RawBitmap&& rawBitmap )
if (nBitCount == 32)
return BitmapEx(aBmp, *pAlphaMask);
else
return aBmp;
return BitmapEx(aBmp);
}
#if ENABLE_CAIRO_CANVAS
......
......@@ -1766,7 +1766,7 @@ BitmapEx GDIMetaFile::ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpPa
else if( rBmpEx.IsTransparent() )
return BitmapEx( aBmp, rBmpEx.GetMask() );
else
return aBmp;
return BitmapEx( aBmp );
}
Color GDIMetaFile::ImplColReplaceFnc( const Color& rColor, const void* pColParam )
......@@ -1930,7 +1930,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol
{
MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pAction);
aMtf.push_back( new MetaBmpScaleAction( pAct->GetPoint(), pAct->GetSize(),
pFncBmp( pAct->GetBitmap(), pBmpParam ).GetBitmap() ) );
pFncBmp( BitmapEx(pAct->GetBitmap()), pBmpParam ).GetBitmap() ) );
}
break;
......@@ -1939,7 +1939,7 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol
MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pAction);
aMtf.push_back( new MetaBmpScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(),
pAct->GetSrcPoint(), pAct->GetSrcSize(),
pFncBmp( pAct->GetBitmap(), pBmpParam ).GetBitmap() )
pFncBmp( BitmapEx(pAct->GetBitmap()), pBmpParam ).GetBitmap() )
);
}
break;
......
......@@ -9780,7 +9780,7 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const
drawBitmap( rTargetArea.TopLeft(), rTargetArea.GetSize(), aBmpEx );
}
else
drawBitmap( rTargetArea.TopLeft(), rTargetArea.GetSize(), aBmp );
drawBitmap( rTargetArea.TopLeft(), rTargetArea.GetSize(), BitmapEx(aBmp) );
return;
}
......
......@@ -493,7 +493,7 @@ BitmapEx OutputDevice::GetBitmapEx( const Point& rSrcPt, const Size& rSize ) con
return BitmapEx(GetBitmap( rSrcPt, rSize ), AlphaMask( aAlphaBitmap ) );
}
else
return GetBitmap( rSrcPt, rSize );
return BitmapEx(GetBitmap( rSrcPt, rSize ));
}
void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize,
......
......@@ -146,7 +146,7 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY,
aVDev->SetBackground( rWallpaper.GetColor() );
aVDev->SetOutputSizePixel( Size( nBmpWidth, nBmpHeight ) );
aVDev->DrawBitmapEx( Point(), aBmpEx );
aBmpEx = aVDev->GetBitmap( Point(), aVDev->GetOutputSizePixel() );
aBmpEx = BitmapEx(aVDev->GetBitmap( Point(), aVDev->GetOutputSizePixel() ));
}
bDrawColorBackground = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment