23 #include <osl/diagnose.h>
44 #include <com/sun/star/beans/XFastPropertySet.hpp>
45 #include <com/sun/star/rendering/MtfRenderer.hpp>
46 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
47 #include <com/sun/star/rendering/XCanvas.hpp>
54 struct ImplColAdjustParam
56 std::unique_ptr<sal_uInt8[]> pMapR;
57 std::unique_ptr<sal_uInt8[]> pMapG;
58 std::unique_ptr<sal_uInt8[]> pMapB;
61 struct ImplBmpAdjustParam
63 short nLuminancePercent;
64 short nContrastPercent;
65 short nChannelRPercent;
66 short nChannelGPercent;
67 short nChannelBPercent;
72 struct ImplColConvertParam
77 struct ImplBmpConvertParam
82 struct ImplColMonoParam
87 struct ImplBmpMonoParam
92 struct ImplColReplaceParam
94 std::unique_ptr<sal_uLong[]> pMinR;
95 std::unique_ptr<sal_uLong[]> pMaxR;
96 std::unique_ptr<sal_uLong[]> pMinG;
97 std::unique_ptr<sal_uLong[]> pMaxG;
98 std::unique_ptr<sal_uLong[]> pMinB;
99 std::unique_ptr<sal_uLong[]> pMaxB;
100 const Color * pDstCols;
104 struct ImplBmpReplaceParam
106 const Color* pSrcCols;
107 const Color* pDstCols;
114 m_nCurrentActionElement( 0 ),
115 m_aPrefSize ( 1, 1 ),
118 m_pOutDev ( nullptr ),
121 m_bUseCanvas ( false )
126 m_nCurrentActionElement( rMtf.m_nCurrentActionElement ),
127 m_aPrefMapMode ( rMtf.m_aPrefMapMode ),
128 m_aPrefSize ( rMtf.m_aPrefSize ),
129 m_pPrev ( rMtf.m_pPrev ),
130 m_pNext ( rMtf.m_pNext ),
131 m_pOutDev ( nullptr ),
134 m_bUseCanvas ( rMtf.m_bUseCanvas )
160 for(pCurrAct = const_cast<GDIMetaFile*>(
this)->
FirstAction();
187 return (nAction <
m_aList.size()) ?
m_aList[ nAction ].
get() :
nullptr;
203 if ( nAction >=
m_aList.size() )
209 std::swap(pAction,
m_aList[nAction]);
247 const size_t nObjCount =
m_aList.size();
258 for(
size_t n = 0;
n < nObjCount;
n++ )
329 const size_t nObjCount =
m_aList.size();
350 const size_t nObjCount =
m_aList.size();
353 if( nPos > nObjCount )
375 if( i++ > nSyncCount )
407 uno::Reference<rendering::XCanvas> xCanvas = win->GetCanvas ();
412 Size aSize (rDestSize.Width () + 1, rDestSize.Height () + 1);
416 uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( xBitmap, uno::UNO_QUERY );
417 if( xBitmapCanvas.is() )
420 uno::Reference< rendering::XMtfRenderer > xMtfRenderer = rendering::MtfRenderer::createWithBitmapCanvas( xContext, xBitmapCanvas );
422 xBitmapCanvas->clear();
423 uno::Reference< beans::XFastPropertySet > xMtfFastPropertySet( xMtfRenderer, uno::UNO_QUERY );
424 if( xMtfFastPropertySet.is() )
428 xMtfFastPropertySet->setFastPropertyValue( 0,
uno::Any( reinterpret_cast<sal_Int64>(
this ) ) );
430 xMtfRenderer->draw( rDestSize.Width(), rDestSize.Height() );
433 if( aBitmapEx.
Create( xBitmapCanvas, aSize ) )
444 catch (
const uno::RuntimeException& )
448 catch (
const uno::Exception&)
463 if( !aDestSize.Width() || !aDestSize.Height() )
473 if( !aTmpPrefSize.Width() )
474 aTmpPrefSize.
setWidth( aDestSize.Width() );
476 if( !aTmpPrefSize.Height() )
477 aTmpPrefSize.setHeight( aDestSize.Height() );
479 Fraction aScaleX( aDestSize.Width(), aTmpPrefSize.Width() );
480 Fraction aScaleY( aDestSize.Height(), aTmpPrefSize.Height() );
496 const Size aEmptySize;
503 bool bIsRecord = (pMtf && pMtf->
IsRecord());
600 double fScaleX, fScaleY;
604 nMoveX = std::abs( aOldPrefSize.
Width() ) - 1;
615 nMoveY = std::abs( aOldPrefSize.
Height() ) - 1;
624 if( ( fScaleX != 1.0 ) || ( fScaleY != 1.0 ) )
626 Scale( fScaleX, fScaleY );
627 Move( nMoveX, nMoveY );
634 const Size aBaseOffset( nX, nY );
635 Size aOffset( aBaseOffset );
638 aMapVDev->EnableOutput(
false );
646 if( pAct->GetRefCount() > 1 )
668 const Size aBaseOffset( nX, nY );
669 Size aOffset( aBaseOffset );
672 aMapVDev->EnableOutput(
false );
673 aMapVDev->SetReferenceDevice( nDPIX, nDPIY );
681 if( pAct->GetRefCount() > 1 )
694 if( aMapVDev->GetMapMode().GetMapUnit() == MapUnit::MapPixel )
696 aOffset = aMapVDev->LogicToPixel( aBaseOffset,
GetPrefMapMode() );
698 aOffset.
setWidth( static_cast<tools::Long>(aOffset.
Width() *
static_cast<double>(
aMap.GetScaleX())) );
699 aOffset.
setHeight( static_cast<tools::Long>(aOffset.
Height() *
static_cast<double>(
aMap.GetScaleY())) );
715 if( pAct->GetRefCount() > 1 )
723 pModAct->
Scale( fScaleX, fScaleY );
732 Scale( static_cast<double>(rScaleX), static_cast<double>(rScaleY) );
740 aMapVDev->EnableOutput(
false );
751 pAct->Execute( aMapVDev.
get() );
756 MetaClipRegionAction* pOldAct =
static_cast<MetaClipRegionAction*
>(pAct);
758 if( pOldAct->IsClipping() )
759 aNewReg.
Intersect( pOldAct->GetRegion() );
760 MetaClipRegionAction* pNewAct =
new MetaClipRegionAction( aNewReg,
true );
767 const Size& rOffset,
double fSin,
double fCos )
772 return Point(
FRound( fCos * nX + fSin * nY ) + rRotatePt.X() + rOffset.
Width(),
773 -
FRound( fSin * nX - fCos * nY ) + rRotatePt.Y() + rOffset.
Height() );
777 const Size& rOffset,
double fSin,
double fCos )
781 aRet.
Rotate( rRotatePt, fSin, fCos );
788 const Size& rOffset,
double fSin,
double fCos )
792 aRet.
Rotate( rRotatePt, fSin, fCos );
805 aVDev->EnableOutput(
false );
809 aVDev->DrawGradient( rPolyPoly, rGrad );
813 for( i=0; i < nAct; ++i )
822 nAngle10 %= 3600_deg10;
823 nAngle10 = ( nAngle10 < 0_deg10 ) ? (
Degree10(3599) + nAngle10 ) : nAngle10;
831 const double fSin = sin( fAngle );
832 const double fCos = cos( fAngle );
838 aMapVDev->EnableOutput(
false );
844 const Size aOffset( -aNewBound.Left(), -aNewBound.Top() );
846 Point aRotAnchor( aOrigin );
847 Size aRotOffset( aOffset );
853 switch( nActionType )
857 MetaPixelAction* pAct =
static_cast<MetaPixelAction*
>(pAction);
859 pAct->GetColor() ) );
888 MetaRoundRectAction* pAct =
static_cast<MetaRoundRectAction*
>(pAction);
889 const tools::Polygon aRoundRectPoly( pAct->GetRect(), pAct->GetHorzRound(), pAct->GetVertRound() );
897 MetaEllipseAction* pAct =
static_cast<MetaEllipseAction*
>(pAction);
898 const tools::Polygon aEllipsePoly( pAct->GetRect().Center(), pAct->GetRect().GetWidth() >> 1, pAct->GetRect().GetHeight() >> 1 );
906 MetaArcAction* pAct =
static_cast<MetaArcAction*
>(pAction);
907 const tools::Polygon aArcPoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Arc );
915 MetaPieAction* pAct =
static_cast<MetaPieAction*
>(pAction);
916 const tools::Polygon aPiePoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Pie );
924 MetaChordAction* pAct =
static_cast<MetaChordAction*
>(pAction);
925 const tools::Polygon aChordPoly( pAct->GetRect(), pAct->GetStartPoint(), pAct->GetEndPoint(), PolyStyle::Chord );
933 MetaPolyLineAction* pAct =
static_cast<MetaPolyLineAction*
>(pAction);
940 MetaPolygonAction* pAct =
static_cast<MetaPolygonAction*
>(pAction);
947 MetaPolyPolygonAction* pAct =
static_cast<MetaPolyPolygonAction*
>(pAction);
962 MetaTextArrayAction* pAct =
static_cast<MetaTextArrayAction*
>(pAction);
964 pAct->GetText(), pAct->GetDXArray(), pAct->GetIndex(), pAct->GetLen() ) );
999 MetaBmpScalePartAction* pAct =
static_cast<MetaBmpScalePartAction*
>(pAction);
1002 BitmapEx aBmpEx( pAct->GetBitmap() );
1026 MetaBmpExScalePartAction* pAct =
static_cast<MetaBmpExScalePartAction*
>(pAction);
1029 BitmapEx aBmpEx( pAct->GetBitmapEx() );
1050 MetaGradientExAction* pAct =
static_cast<MetaGradientExAction*
>(pAction);
1052 pAct->GetGradient() ) );
1060 if( pCommentAct->
GetComment() ==
"XGRAD_SEQ_BEGIN" )
1062 int nBeginComments( 1 );
1073 MetaGradientExAction* pAct =
static_cast<MetaGradientExAction*
>(pAction);
1076 pAct->GetGradient() );
1087 if( !nBeginComments )
1090 else if( pAct->
GetComment() ==
"XGRAD_SEQ_BEGIN" )
1103 bool bPathStroke = (pCommentAct->
GetComment() ==
"XPATHSTROKE_SEQ_BEGIN");
1104 if ( bPathStroke || pCommentAct->
GetComment() ==
"XPATHFILL_SEQ_BEGIN" )
1119 static_cast<const sal_uInt8*>( aDest.GetData()), aDest.Tell() ) );
1130 static_cast<const sal_uInt8*>( aDest.GetData()), aDest.Tell() ) );
1134 else if ( pCommentAct->
GetComment() ==
"XPATHSTROKE_SEQ_END"
1135 || pCommentAct->
GetComment() ==
"XPATHFILL_SEQ_END" )
1137 pAction->Execute( aMapVDev.
get() );
1149 aHatch.
SetAngle( aHatch.GetAngle() + nAngle10 );
1170 aTransMtf.Rotate( nAngle10 );
1183 aEPSMtf.Rotate( nAngle10 );
1191 MetaClipRegionAction* pAct =
static_cast<MetaClipRegionAction*
>(pAction);
1193 if( pAct->IsClipping() && pAct->GetRegion().HasPolyPolygonOrB2DPolyPolygon() )
1204 MetaISectRectClipRegionAction* pAct =
static_cast<MetaISectRectClipRegionAction*
>(pAction);
1207 aRotOffset, fSin, fCos )) ) );
1213 MetaISectRegionClipRegionAction* pAct =
static_cast<MetaISectRegionClipRegionAction*
>(pAction);
1227 MetaRefPointAction* pAct =
static_cast<MetaRefPointAction*
>(pAction);
1228 aMtf.
AddAction(
new MetaRefPointAction(
ImplGetRotatedPoint( pAct->GetRefPoint(), aRotAnchor, aRotOffset, fSin, fCos ), pAct->IsSetting() ) );
1234 MetaFontAction* pAct =
static_cast<MetaFontAction*
>(pAction);
1238 aMtf.
AddAction(
new MetaFontAction( aFont ) );
1251 OSL_FAIL(
"GDIMetaFile::Rotate(): unsupported action" );
1257 pAction->Execute( aMapVDev.
get() );
1282 const std::vector<tools::Rectangle>& i_rClipStack,
1286 if( ! i_rInBounds.
IsEmpty() && ! i_rClipStack.empty() && ! i_rClipStack.back().IsEmpty() )
1291 if( ! o_rOutBounds.
IsEmpty() )
1292 o_rOutBounds.
Union( aBounds );
1294 o_rOutBounds = aBounds;
1298 if( ! o_pHairline->
IsEmpty() )
1299 o_pHairline->
Union( aBounds );
1301 *o_pHairline = aBounds;
1309 aMapVDev->EnableOutput(
false );
1313 std::vector<PushFlags> aPushFlagStack;
1326 tools::Rectangle* pUseHairline = (pHairline && aMapVDev->IsLineColor()) ? pHairline :
nullptr;
1328 switch( nActionType )
1332 MetaPixelAction* pAct =
static_cast<MetaPixelAction*
>(pAction);
1336 aClipStack, pUseHairline );
1346 aClipStack, pUseHairline );
1361 if(0 != rLineInfo.GetWidth())
1362 pUseHairline =
nullptr;
1378 MetaRoundRectAction* pAct =
static_cast<MetaRoundRectAction*
>(pAction);
1385 MetaEllipseAction* pAct =
static_cast<MetaEllipseAction*
>(pAction);
1392 MetaArcAction* pAct =
static_cast<MetaArcAction*
>(pAction);
1401 MetaPieAction* pAct =
static_cast<MetaPieAction*
>(pAction);
1410 MetaChordAction* pAct =
static_cast<MetaChordAction*
>(pAction);
1419 MetaPolyLineAction* pAct =
static_cast<MetaPolyLineAction*
>(pAction);
1424 const LineInfo& rLineInfo = pAct->GetLineInfo();
1426 if(0 != rLineInfo.GetWidth())
1427 pUseHairline =
nullptr;
1436 MetaPolygonAction* pAct =
static_cast<MetaPolygonAction*
>(pAction);
1444 MetaPolyPolygonAction* pAct =
static_cast<MetaPolyPolygonAction*
>(pAction);
1457 aRect.
Move( aPt.X(), aPt.Y() );
1464 MetaTextArrayAction* pAct =
static_cast<MetaTextArrayAction*
>(pAction);
1467 aMapVDev->GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
1468 0, pAct->GetDXArray() );
1469 Point aPt( pAct->GetPoint() );
1470 aRect.
Move( aPt.X(), aPt.Y() );
1483 aRect.
Move( aPt.X(), aPt.Y() );
1492 static constexpr OUStringLiteral pStr =
u"\u00c4g";
1493 OUString
aStr( pStr );
1496 aMapVDev->GetTextBoundRect( aRect, aStr, 0, 0, aStr.getLength() );
1498 aRect.
Move( aPt.X(), aPt.Y() );
1514 MetaBmpScalePartAction* pAct =
static_cast<MetaBmpScalePartAction*
>(pAction);
1530 MetaBmpExScalePartAction* pAct =
static_cast<MetaBmpExScalePartAction*
>(pAction);
1546 MetaGradientExAction* pAct =
static_cast<MetaGradientExAction*
>(pAction);
1594 MetaClipRegionAction* pAct =
static_cast<MetaClipRegionAction*
>(pAction);
1595 if( pAct->IsClipping() )
1604 MetaISectRectClipRegionAction* pAct =
static_cast<MetaISectRectClipRegionAction*
>(pAction);
1606 if( aClipStack.back().IsEmpty() )
1607 aClipStack.back() = aRect;
1615 MetaISectRegionClipRegionAction* pAct =
static_cast<MetaISectRegionClipRegionAction*
>(pAction);
1617 if( aClipStack.back().IsEmpty() )
1618 aClipStack.back() = aRect;
1666 MetaWallpaperAction* pAct =
static_cast<MetaWallpaperAction*
>(pAction);
1682 MetaMoveClipRegionAction* pAct =
static_cast<MetaMoveClipRegionAction*
>(pAction);
1683 if( ! aClipStack.back().IsEmpty() )
1685 Size aDelta( pAct->GetHorzMove(), pAct->GetVertMove() );
1687 aClipStack.back().Move( aDelta.Width(), aDelta.Width() );
1698 MetaPushAction* pAct =
static_cast<MetaPushAction*
>(pAction);
1699 aPushFlagStack.push_back( pAct->GetFlags() );
1703 aClipStack.push_back( aRect );
1709 if( ! aPushFlagStack.empty() )
1713 if( aClipStack.size() > 1 )
1714 aClipStack.pop_back();
1716 aPushFlagStack.pop_back();
1729 static_cast<const ImplColAdjustParam*
>(pColParam)->pMapR[ rColor.
GetRed() ],
1730 static_cast<const ImplColAdjustParam*
>(pColParam)->pMapG[ rColor.
GetGreen() ],
1731 static_cast<const ImplColAdjustParam*
>(pColParam)->pMapB[ rColor.
GetBlue() ] );
1737 const ImplBmpAdjustParam*
p =
static_cast<const ImplBmpAdjustParam*
>(pBmpParam);
1740 aRet.
Adjust( p->nLuminancePercent, p->nContrastPercent,
1741 p->nChannelRPercent, p->nChannelGPercent, p->nChannelBPercent,
1742 p->fGamma, p->bInvert );
1752 cLum = ( cLum < 128 ) ? 0 : 255;
1761 aRet.
Convert( static_cast<const ImplBmpConvertParam*>(pBmpParam)->eConversion );
1768 return static_cast<const ImplColMonoParam*
>(pColParam)->aColor;
1777 aPal[ 2 ] =
static_cast<const ImplBmpMonoParam*
>(pBmpParam)->aColor;
1780 aBmp.
Erase( static_cast<const ImplBmpMonoParam*>(pBmpParam)->aColor );
1794 for(
sal_uLong i = 0; i < static_cast<const ImplColReplaceParam*>(pColParam)->
nCount;
i++ )
1796 if( ( static_cast<const ImplColReplaceParam*>(pColParam)->pMinR[
i ] <= nR ) &&
1797 (
static_cast<const ImplColReplaceParam*
>(pColParam)->pMaxR[
i ] >= nR ) &&
1798 (
static_cast<const ImplColReplaceParam*
>(pColParam)->pMinG[
i ] <= nG ) &&
1799 (
static_cast<const ImplColReplaceParam*
>(pColParam)->pMaxG[
i ] >= nG ) &&
1800 (
static_cast<const ImplColReplaceParam*
>(pColParam)->pMinB[
i ] <= nB ) &&
1801 (
static_cast<const ImplColReplaceParam*
>(pColParam)->pMaxB[
i ] >= nB ) )
1803 return static_cast<const ImplColReplaceParam*
>(pColParam)->pDstCols[
i ];
1812 const ImplBmpReplaceParam*
p =
static_cast<const ImplBmpReplaceParam*
>(pBmpParam);
1815 aRet.
Replace( p->pSrcCols, p->pDstCols, p->nCount );
1837 MetaPixelAction* pAct =
static_cast<MetaPixelAction*
>(pAction);
1838 aMtf.
push_back(
new MetaPixelAction( pAct->GetPoint(), pFncCol( pAct->GetColor(), pColParam ) ) );
1866 MetaTextColorAction* pAct =
static_cast<MetaTextColorAction*
>(pAction);
1867 aMtf.
push_back(
new MetaTextColorAction( pFncCol( pAct->GetColor(), pColParam ) ) );
1873 MetaTextFillColorAction* pAct =
static_cast<MetaTextFillColorAction*
>(pAction);
1875 if( pAct->IsSetting() )
1876 pAct =
new MetaTextFillColorAction( pFncCol( pAct->GetColor(), pColParam ),
true );
1884 MetaTextLineColorAction* pAct =
static_cast<MetaTextLineColorAction*
>(pAction);
1886 if( pAct->IsSetting() )
1887 pAct =
new MetaTextLineColorAction( pFncCol( pAct->GetColor(), pColParam ),
true );
1895 MetaOverlineColorAction* pAct =
static_cast<MetaOverlineColorAction*
>(pAction);
1897 if( pAct->IsSetting() )
1898 pAct =
new MetaOverlineColorAction( pFncCol( pAct->GetColor(), pColParam ),
true );
1906 MetaFontAction* pAct =
static_cast<MetaFontAction*
>(pAction);
1909 aFont.
SetColor( pFncCol( aFont.GetColor(), pColParam ) );
1910 aFont.SetFillColor( pFncCol( aFont.GetFillColor(), pColParam ) );
1911 aMtf.
push_back(
new MetaFontAction( aFont ) );
1917 MetaWallpaperAction* pAct =
static_cast<MetaWallpaperAction*
>(pAction);
1918 Wallpaper aWall( pAct->GetWallpaper() );
1921 aWall.SetColor( pFncCol( aWall.GetColor(), pColParam ) );
1923 if( aWall.IsBitmap() )
1924 aWall.SetBitmap( pFncBmp( aWall.GetBitmap(), pBmpParam ) );
1926 if( aWall.IsGradient() )
1928 Gradient aGradient( aWall.GetGradient() );
1930 aGradient.
SetStartColor( pFncCol( aGradient.GetStartColor(), pColParam ) );
1931 aGradient.SetEndColor( pFncCol( aGradient.GetEndColor(), pColParam ) );
1932 aWall.SetGradient( aGradient );
1935 aMtf.
push_back(
new MetaWallpaperAction( rRect, aWall ) );
1943 OSL_FAIL(
"Don't use bitmap actions of this type in metafiles!" );
1957 MetaBmpScalePartAction* pAct =
static_cast<MetaBmpScalePartAction*
>(pAction);
1958 aMtf.
push_back(
new MetaBmpScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(),
1959 pAct->GetSrcPoint(), pAct->GetSrcSize(),
1960 pFncBmp(
BitmapEx(pAct->GetBitmap()), pBmpParam ).GetBitmap() )
1976 MetaBmpExScalePartAction* pAct =
static_cast<MetaBmpExScalePartAction*
>(pAction);
1977 aMtf.
push_back(
new MetaBmpExScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(),
1978 pAct->GetSrcPoint(), pAct->GetSrcSize(),
1979 pFncBmp( pAct->GetBitmapEx(), pBmpParam ) )
1989 pFncCol( pAct->
GetColor(), pColParam ) )
2000 pFncCol( pAct->
GetColor(), pColParam ) )
2010 aGradient.
SetStartColor( pFncCol( aGradient.GetStartColor(), pColParam ) );
2011 aGradient.SetEndColor( pFncCol( aGradient.GetEndColor(), pColParam ) );
2018 MetaGradientExAction* pAct =
static_cast<MetaGradientExAction*
>(pAction);
2019 Gradient aGradient( pAct->GetGradient() );
2021 aGradient.
SetStartColor( pFncCol( aGradient.GetStartColor(), pColParam ) );
2022 aGradient.SetEndColor( pFncCol( aGradient.GetEndColor(), pColParam ) );
2023 aMtf.
push_back(
new MetaGradientExAction( pAct->GetPolyPolygon(), aGradient ) );
2032 aHatch.
SetColor( pFncCol( aHatch.GetColor(), pColParam ) );
2074 short nChannelRPercent,
short nChannelGPercent,
2075 short nChannelBPercent,
double fGamma,
bool bInvert,
bool msoBrightness )
2078 if( !(nLuminancePercent || nContrastPercent ||
2079 nChannelRPercent || nChannelGPercent || nChannelBPercent ||
2080 ( fGamma != 1.0 ) || bInvert) )
2083 double fM, fROff, fGOff, fBOff, fOff;
2084 ImplColAdjustParam aColParam;
2085 ImplBmpAdjustParam aBmpParam;
2087 aColParam.pMapR.reset(
new sal_uInt8[ 256 ]);
2088 aColParam.pMapG.reset(
new sal_uInt8[ 256 ]);
2089 aColParam.pMapB.reset(
new sal_uInt8[ 256 ]);
2092 if( nContrastPercent >= 0 )
2093 fM = 128.0 / ( 128.0 - 1.27 *
MinMax( nContrastPercent, 0, 100 ) );
2095 fM = ( 128.0 + 1.27 *
MinMax( nContrastPercent, -100, 0 ) ) / 128.0;
2099 fOff =
MinMax( nLuminancePercent, -100, 100 ) * 2.55 + 128.0 - fM * 128.0;
2101 fOff =
MinMax( nLuminancePercent, -100, 100 ) * 2.55;
2104 fROff = nChannelRPercent * 2.55 + fOff;
2105 fGOff = nChannelGPercent * 2.55 + fOff;
2106 fBOff = nChannelBPercent * 2.55 + fOff;
2109 fGamma = ( fGamma <= 0.0 || fGamma > 10.0 ) ? 1.0 : ( 1.0 / fGamma );
2110 const bool bGamma = ( fGamma != 1.0 );
2123 aColParam.pMapR[ nX ] =
static_cast<sal_uInt8>(
MinMax(
FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 ));
2124 aColParam.pMapG[ nX ] =
static_cast<sal_uInt8>(
MinMax(
FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 ));
2125 aColParam.pMapB[ nX ] =
static_cast<sal_uInt8>(
MinMax(
FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 ));
2129 aColParam.pMapR[ nX ] =
GAMMA( aColParam.pMapR[ nX ], fGamma );
2130 aColParam.pMapG[ nX ] =
GAMMA( aColParam.pMapG[ nX ], fGamma );
2131 aColParam.pMapB[ nX ] =
GAMMA( aColParam.pMapB[ nX ], fGamma );
2136 aColParam.pMapR[ nX ] = ~aColParam.pMapR[ nX ];
2137 aColParam.pMapG[ nX ] = ~aColParam.pMapG[ nX ];
2138 aColParam.pMapB[ nX ] = ~aColParam.pMapB[ nX ];
2142 aBmpParam.nLuminancePercent = nLuminancePercent;
2143 aBmpParam.nContrastPercent = nContrastPercent;
2144 aBmpParam.nChannelRPercent = nChannelRPercent;
2145 aBmpParam.nChannelGPercent = nChannelGPercent;
2146 aBmpParam.nChannelBPercent = nChannelBPercent;
2147 aBmpParam.fGamma = fGamma;
2148 aBmpParam.bInvert = bInvert;
2156 ImplColConvertParam aColParam;
2157 ImplBmpConvertParam aBmpParam;
2159 aColParam.eConversion = eConversion;
2167 ImplColReplaceParam aColParam;
2168 ImplBmpReplaceParam aBmpParam;
2170 aColParam.pMinR.reset(
new sal_uLong[ nColorCount ]);
2171 aColParam.pMaxR.reset(
new sal_uLong[ nColorCount ]);
2172 aColParam.pMinG.reset(
new sal_uLong[ nColorCount ]);
2173 aColParam.pMaxG.reset(
new sal_uLong[ nColorCount ]);
2174 aColParam.pMinB.reset(
new sal_uLong[ nColorCount ]);
2175 aColParam.pMaxB.reset(
new sal_uLong[ nColorCount ]);
2181 nVal = pSearchColors[
i ].
GetRed();
2189 nVal = pSearchColors[
i ].
GetBlue();
2194 aColParam.pDstCols = pReplaceColors;
2195 aColParam.nCount = nColorCount;
2197 aBmpParam.pSrcCols = pSearchColors;
2198 aBmpParam.pDstCols = pReplaceColors;
2199 aBmpParam.nCount = nColorCount;
2208 ImplColMonoParam aColParam;
2209 ImplBmpMonoParam aBmpParam;
2211 aColParam.aColor = rColor;
2212 aBmpParam.aColor = rColor;
2239 ShortToSVBT16( static_cast<sal_uInt16>(pAct->
GetType()), aBT16 );
2245 Int32ToSVBT32( pAct->
GetPoint().X(), aBT32 );
2248 Int32ToSVBT32( pAct->
GetPoint().Y(), aBT32 );
2257 ShortToSVBT16( static_cast<sal_uInt16>(pAct->
GetType()), aBT16 );
2263 Int32ToSVBT32( pAct->
GetPoint().X(), aBT32 );
2266 Int32ToSVBT32( pAct->
GetPoint().Y(), aBT32 );
2279 MetaBmpScalePartAction* pAct =
static_cast<MetaBmpScalePartAction*
>(pAction);
2281 ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2284 BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
2287 Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
2290 Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
2293 Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
2296 Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
2299 Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
2302 Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
2305 Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
2308 Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
2317 ShortToSVBT16( static_cast<sal_uInt16>(pAct->
GetType()), aBT16 );
2323 Int32ToSVBT32( pAct->
GetPoint().X(), aBT32 );
2326 Int32ToSVBT32( pAct->
GetPoint().Y(), aBT32 );
2335 ShortToSVBT16( static_cast<sal_uInt16>(pAct->
GetType()), aBT16 );
2341 Int32ToSVBT32( pAct->
GetPoint().X(), aBT32 );
2344 Int32ToSVBT32( pAct->
GetPoint().Y(), aBT32 );
2357 MetaBmpExScalePartAction* pAct =
static_cast<MetaBmpExScalePartAction*
>(pAction);
2359 ShortToSVBT16( static_cast<sal_uInt16>(pAct->GetType()), aBT16 );
2362 BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA );
2365 Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
2368 Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
2371 Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
2374 Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
2377 Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
2380 Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
2383 Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
2386 Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
2395 ShortToSVBT16( static_cast<sal_uInt16>(pAct->
GetType()), aBT16 );
2401 UInt32ToSVBT32( sal_uInt32(pAct->
GetColor()), aBT32 );
2404 Int32ToSVBT32( pAct->
GetPoint().X(), aBT32 );
2407 Int32ToSVBT32( pAct->
GetPoint().Y(), aBT32 );
2416 ShortToSVBT16( static_cast<sal_uInt16>(pAct->
GetType()), aBT16 );
2422 UInt32ToSVBT32( sal_uInt32(pAct->
GetColor()), aBT32 );
2425 Int32ToSVBT32( pAct->
GetPoint().X(), aBT32 );
2428 Int32ToSVBT32( pAct->
GetPoint().Y(), aBT32 );
2443 ShortToSVBT16( static_cast<sal_uInt16>(pAct->
GetType()), aBT16 );
2449 UInt32ToSVBT32( sal_uInt32(pAct->
GetColor()), aBT32 );
2487 MetaClipRegionAction& rAct =
static_cast<MetaClipRegionAction&
>(*pAction);
2498 for(
auto const& rPolygon : aPolyPolygon)
2500 const sal_uInt32 nPointCount(rPolygon.count());
2501 const bool bControl(rPolygon.areControlPointsUsed());
2503 for(sal_uInt32 b(0); b < nPointCount; b++)
2507 DoubleToSVBT64(aPoint.getX(), aSVBT64);
2509 DoubleToSVBT64(aPoint.getY(), aSVBT64);
2514 if(rPolygon.isPrevControlPointUsed(b))
2518 DoubleToSVBT64(aCtrl.getX(), aSVBT64);
2520 DoubleToSVBT64(aCtrl.getY(), aSVBT64);
2524 if(rPolygon.isNextControlPointUsed(b))
2528 DoubleToSVBT64(aCtrl.getX(), aSVBT64);
2530 DoubleToSVBT64(aCtrl.getY(), aSVBT64);
2542 pAction->
Write( aMemStm, &aWriteData );
2551 pAction->
Write( aMemStm, &aWriteData );
2589 case MetaActionType::POLYGON: nSizeBytes +=
static_cast<MetaPolygonAction*
>( pAction )->GetPolygon().GetSize() *
sizeof(
Point );
break;
2592 const tools::PolyPolygon& rPolyPoly =
static_cast<MetaPolyPolygonAction*
>( pAction )->GetPolyPolygon();
2594 for( sal_uInt16
n = 0;
n < rPolyPoly.
Count(); ++
n )
2595 nSizeBytes += ( rPolyPoly[
n ].GetSize() *
sizeof(
Point ) );
2604 MetaTextArrayAction* pTextArrayAction =
static_cast<MetaTextArrayAction*
>(pAction);
2606 nSizeBytes += ( pTextArrayAction->GetText().getLength() *
sizeof(
sal_Unicode ) );
2608 if( pTextArrayAction->GetDXArray() )
2609 nSizeBytes += ( pTextArrayAction->GetLen() << 2 );
2625 rtl_TextEncoding m_eOrigCharSet;
2629 , m_eOrigCharSet(m_rData.meActualCharSet)
2634 bool TooDeep()
const {
return m_rData.
mnParseDepth > 1024; }
2654 rIStm.
SetEndian( SvStreamEndian::LITTLE );
2663 if ( !strcmp( aId,
"VCLMTF" ) )
2666 sal_uInt32 nStmCompressMode = 0;
2668 std::unique_ptr<VersionCompatRead> pCompat(
new VersionCompatRead(rIStm));
2678 std::unique_ptr<ImplMetaReadData> xReadData;
2682 pData = xReadData.get();
2684 DepthGuard aDepthGuard(*pData, rIStm);
2686 if (aDepthGuard.TooDeep())
2687 throw std::runtime_error(
"too much recursion");
2689 for( sal_uInt32 nAction = 0; ( nAction < nCount ) && !rIStm.
eof(); nAction++ )
2697 if ( pCommentAct->
GetComment() ==
"EMF_PLUS" )
2706 rIStm.
Seek( nStmPos );
2712 SAL_WARN(
"vcl",
"GDIMetaFile exception during load");
2719 rGDIMetaFile.
Clear();
2720 rIStm.
Seek( nStmPos );
2749 rOStm.
SetEndian( SvStreamEndian::LITTLE );
2753 VersionCompatWrite aCompat(rOStm, 1);
2755 rOStm.
WriteUInt32(static_cast<sal_uInt32>(nStmCompressMode));
2769 pAct->
Write( rOStm, &aWriteData );
2786 const Point aNullPt;
2790 Size aSizePix( std::abs( aBRPix.X() - aTLPix.X() ) + 1, std::abs( aBRPix.Y() - aTLPix.Y() ) + 1 );
2791 sal_uInt32 nMaximumExtent = 256;
2798 if ( aSizePix.Width() && aSizePix.Height()
2799 && ( sal::static_int_cast<
tools::ULong >(aSizePix.Width()) >
2801 sal::static_int_cast< tools::ULong >(aSizePix.Height()) >
2804 const Size aOldSizePix( aSizePix );
2805 double fWH =
static_cast< double >( aSizePix.Width() ) / aSizePix.Height();
2809 aSizePix.setWidth(
FRound( nMaximumExtent * fWH ) );
2810 aSizePix.setHeight( nMaximumExtent );
2814 aSizePix.setWidth( nMaximumExtent );
2815 aSizePix.setHeight(
FRound( nMaximumExtent / fWH ) );
2818 aDrawSize.setWidth(
FRound( ( static_cast< double >( aDrawSize.Width() ) * aSizePix.Width() ) / aOldSizePix.
Width() ) );
2819 aDrawSize.setHeight(
FRound( ( static_cast< double >( aDrawSize.Height() ) * aSizePix.Height() ) / aOldSizePix.
Height() ) );
2824 Size aAntialiasSize(aSizePix.Width() * 4, aSizePix.Height() * 4);
2825 if (aVDev->SetOutputSizePixel(aAntialiasSize))
2828 Size aAntialias(aDrawSize.Width() * 4, aDrawSize.Height() * 4);
2835 BitmapEx aBitmap( aVDev->GetBitmapEx( aNullPt, aVDev->GetOutputSizePixel() ) );
2838 aBitmap.
Scale(aDrawSize, nScaleFlag);
2842 if (aSize.Width() && aSize.Height())
2843 aBitmap.
Convert(eColorConversion);
2845 rBitmapEx = aBitmap;
2858 SvFileStream aStream(pFileName ? OUString::fromUtf8(pFileName) : OUString(
"file:///tmp/metafile.xml"),
2859 StreamMode::STD_READWRITE | StreamMode::TRUNC);
2862 aDumper.
dump(*
this, aStream);
const Fraction & GetScaleX() const
void SetDigitLanguage(LanguageType)
void SetPixelOffset(const Size &rOffset)
Set an offset in pixel.
sal_uInt64 BitmapChecksum
sal_uInt8 GetAlpha() const
void setWidth(tools::Long nWidth)
void Replace(const Color &rSearchColor, const Color &rReplaceColor)
Replace all pixel having the search color with the specified color.
bool Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, double fGamma=1.0, bool bInvert=false, bool msoBrightness=false)
Change various global color characteristics.
SvStream & WriteMapMode(SvStream &rOStm, const MapMode &rMapMode)
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
#define GAMMA(_def_cVal, _def_InvGamma)
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
std::enable_if< std::is_signed< T >::value||std::is_floating_point< T >::value, long >::type MinMax(T nVal, tools::Long nMin, tools::Long nMax)
sal_uInt8 GetLuminance() const
Encapsulates geometry and associated attributes of a graphical 'pen stroke'.
sal_uInt64 Seek(sal_uInt64 nPos)
const MapMode & GetMapMode() const
void SetLayoutMode(ComplexTextLayoutFlags nTextLayoutMode)
BitmapChecksum vcl_get_checksum(BitmapChecksum Checksum, const void *Data, sal_uInt32 DatLen)
GDIMetaFile * GetConnectMetaFile() const
const OUString & GetText() const
Size GetSizePixel() const
SvStreamCompressFlags GetCompressMode() const
const sal_uInt8 * GetData() const
bool Convert(BmpConversion eConversion)
Convert bitmap format.
BitmapChecksum GetChecksum() const
HashMap_OWString_Interface aMap
const Sequence< Sequence< double > > & m_rData
const OUString & GetText() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
const Fraction & GetScaleY() const
SvStream & WriteGDIMetaFile(SvStream &rOStm, const GDIMetaFile &rGDIMetaFile)
void SetStartColor(const Color &rColor)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
BitmapEx(* BmpExchangeFnc)(const BitmapEx &rBmpEx, const void *pBmpParam)
sal_uInt8 GetBlue() const
FontLineStyle GetUnderline() const
tools::PolyPolygon GetAsPolyPolygon() const
void setPath(const tools::PolyPolygon &rPath)
Set path to fill.
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
static vcl::Window * GetFirstTopLevelWindow()
Get the first top-level window of the application.
bool Create(const css::uno::Reference< css::rendering::XBitmapCanvas > &xBitmapCanvas, const Size &rSize)
populate from a canvas implementation
#define BITMAP_CHECKSUM_SIZE
UNDERLYING_TYPE get() const
void SetConnectMetaFile(GDIMetaFile *pMtf)
void SetScaleX(const Fraction &rScaleX)
#define TOOLS_WARN_EXCEPTION(area, stream)
tools::Long GetWidth() const
void SetAngle(Degree10 nAngle10)
const Point & GetPoint() const
tools::Long FRound(double fVal)
BitmapChecksum GetChecksum() const
void SetOrientation(Degree10 nLineOrientation)
Color(* ColorExchangeFnc)(const Color &rColor, const void *pColParam)
Size GetOutputSize() const
void SetOrigin(const Point &rOrigin)
sal_uInt32 GetWidth() const
tools::Long Width() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
std::size_t WriteBytes(const void *pData, std::size_t nSize)
void SetScaleY(const Fraction &rScaleY)
void SetError(ErrCode nErrorCode)
void Intersect(const tools::Rectangle &rRegion)
void getPath(tools::Polygon &) const
Query path to stroke.
Size GetOutputSizePixel() const
MapUnit GetMapUnit() const
virtual void SetMetafileMapMode(const MapMode &rNewMapMode, bool bIsRecord)
bool IsTransparent() const
bool Rotate(Degree10 nAngle10, const Color &rFillColor)
Rotate bitmap by the specified angle.
static vcl::Window * GetActiveTopWindow()
Get the "active" top window.
FontStrikeout GetStrikeout() const
void SetColor(const Color &)
std::size_t ReadBytes(void *pData, std::size_t nSize)
Point PixelToLogic(const Point &rDevicePt) const
Point LogicToPixel(const Point &rLogicPt) const
const Point & GetPoint() const
sal_uInt8 GetGreen() const
SvStreamEndian GetEndian() const
AlphaMask GetAlpha() const
void BCToBCOA(BitmapChecksum n, BitmapChecksumOctetArray p)
const Point & GetStartPoint() const
SvStream & ReadGDIMetaFile(SvStream &rIStm, GDIMetaFile &rGDIMetaFile, ImplMetaReadData *pData)
void SetEndian(SvStreamEndian SvStreamEndian)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
#define SAL_INFO(area, stream)
#define SVSTREAM_FILEFORMAT_ERROR
rtl_TextEncoding GetStreamCharSet() const
tools::Long Height() const
bool HasPolyPolygonOrB2DPolyPolygon() const
Reference< XComponentContext > getProcessComponentContext()
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
void setPath(const tools::Polygon &)
Set path to stroke.
FontLineStyle GetOverline() const
bool Erase(const Color &rFillColor)
Fill the entire bitmap with the given color.
void setHeight(tools::Long nHeight)
basegfx::B2DPolyPolygon GetAsB2DPolyPolygon() const
sal_uInt32 GetDataSize() const
reference_type * get() const
Get the body.
Size GetPixelOffset() const
Get the offset in pixel.
#define SAL_WARN(area, stream)
DepthGuard(HWPFile &rFile)
sal_uInt8 BitmapChecksumOctetArray[BITMAP_CHECKSUM_SIZE]
SvStream & ReadMapMode(SvStream &rIStm, MapMode &rMapMode)
Encapsulates geometry and associated attributes of a filled area.
static void ImplActionBounds(tools::Rectangle &o_rOutBounds, const tools::Rectangle &i_rInBounds, const std::vector< tools::Rectangle > &i_rClipStack, tools::Rectangle *o_pHairline)
virtual size_t GetSyncCount() const
void getPath(tools::PolyPolygon &) const
Query path to fill.
Converts old SVGDI aka SVM1 format data to current VCLMTF aka SVM2 format metafile data...
const Size & GetSizePixel() const
void Push(PushFlags nFlags=PushFlags::ALL)
void SetColor(const Color &rColor)
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
const tools::Rectangle & GetRect() const
sal_Int32 GetIndex() const
sal_Int32 GetIndex() const