summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2020-12-24 09:35:22 +1100
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-01-08 11:02:09 +0100
commit6bc1de9b410e118aa15bdade6ad2c3644843e21e (patch)
treeb229090dfd44d7810485f6d3cd14cda12a4692ac /vcl/source
parente27be8cf095d0a71866d2a415e958ee599c6b360 (diff)
vcl: move ImplPrintTransparent() from OutputDevice to Printer
Change-Id: I6950bdca72b93b34621e0b108c2c8060c59d98d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108247 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/print.cxx92
-rw-r--r--vcl/source/outdev/transparent.cxx92
2 files changed, 92 insertions, 92 deletions
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index bb99579fcafc..bbfac98a1797 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -181,6 +181,98 @@ void PrinterOptions::ReadFromConfig( bool i_bFile )
*this = aOldValues;
}
+void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask,
+ const Point& rDestPt, const Size& rDestSize,
+ const Point& rSrcPtPixel, const Size& rSrcSizePixel )
+{
+ Point aDestPt( LogicToPixel( rDestPt ) );
+ Size aDestSz( LogicToPixel( rDestSize ) );
+ tools::Rectangle aSrcRect( rSrcPtPixel, rSrcSizePixel );
+
+ aSrcRect.Justify();
+
+ if( rBmp.IsEmpty() || !aSrcRect.GetWidth() || !aSrcRect.GetHeight() || !aDestSz.Width() || !aDestSz.Height() )
+ return;
+
+ Bitmap aPaint( rBmp ), aMask( rMask );
+ BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE;
+
+ if( aMask.GetBitCount() > 1 )
+ aMask.Convert( BmpConversion::N1BitThreshold );
+
+ // mirrored horizontically
+ if( aDestSz.Width() < 0 )
+ {
+ aDestSz.setWidth( -aDestSz.Width() );
+ aDestPt.AdjustX( -( aDestSz.Width() - 1 ) );
+ nMirrFlags |= BmpMirrorFlags::Horizontal;
+ }
+
+ // mirrored vertically
+ if( aDestSz.Height() < 0 )
+ {
+ aDestSz.setHeight( -aDestSz.Height() );
+ aDestPt.AdjustY( -( aDestSz.Height() - 1 ) );
+ nMirrFlags |= BmpMirrorFlags::Vertical;
+ }
+
+ // source cropped?
+ if( aSrcRect != tools::Rectangle( Point(), aPaint.GetSizePixel() ) )
+ {
+ aPaint.Crop( aSrcRect );
+ aMask.Crop( aSrcRect );
+ }
+
+ // destination mirrored
+ if( nMirrFlags != BmpMirrorFlags::NONE )
+ {
+ aPaint.Mirror( nMirrFlags );
+ aMask.Mirror( nMirrFlags );
+ }
+
+ // we always want to have a mask
+ if( aMask.IsEmpty() )
+ {
+ aMask = Bitmap( aSrcRect.GetSize(), 1 );
+ aMask.Erase( COL_BLACK );
+ }
+
+ // do painting
+ const tools::Long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight();
+ tools::Long nX, nY; // , nWorkX, nWorkY, nWorkWidth, nWorkHeight;
+ std::unique_ptr<tools::Long[]> pMapX(new tools::Long[ nSrcWidth + 1 ]);
+ std::unique_ptr<tools::Long[]> pMapY(new tools::Long[ nSrcHeight + 1 ]);
+ const bool bOldMap = mbMap;
+
+ mbMap = false;
+
+ // create forward mapping tables
+ for( nX = 0; nX <= nSrcWidth; nX++ )
+ pMapX[ nX ] = aDestPt.X() + FRound( static_cast<double>(aDestSz.Width()) * nX / nSrcWidth );
+
+ for( nY = 0; nY <= nSrcHeight; nY++ )
+ pMapY[ nY ] = aDestPt.Y() + FRound( static_cast<double>(aDestSz.Height()) * nY / nSrcHeight );
+
+ // walk through all rectangles of mask
+ const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel())));
+ RectangleVector aRectangles;
+ aWorkRgn.GetRegionRectangles(aRectangles);
+
+ for (auto const& rectangle : aRectangles)
+ {
+ const Point aMapPt(pMapX[rectangle.Left()], pMapY[rectangle.Top()]);
+ const Size aMapSz( pMapX[rectangle.Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1
+ pMapY[rectangle.Bottom() + 1] - aMapPt.Y()); // same for Y
+ Bitmap aBandBmp(aPaint);
+
+ aBandBmp.Crop(rectangle);
+ DrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp);
+ }
+
+ mbMap = bOldMap;
+
+}
+
bool Printer::DrawTransformBitmapExDirect(
const basegfx::B2DHomMatrix& /*aFullTransform*/,
const BitmapEx& /*rBitmapEx*/)
diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index 28a030963018..49c8bfa23e07 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -107,98 +107,6 @@ Color OutputDevice::ImplDrawModeToColor( const Color& rColor ) const
return aColor;
}
-void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask,
- const Point& rDestPt, const Size& rDestSize,
- const Point& rSrcPtPixel, const Size& rSrcSizePixel )
-{
- Point aDestPt( LogicToPixel( rDestPt ) );
- Size aDestSz( LogicToPixel( rDestSize ) );
- tools::Rectangle aSrcRect( rSrcPtPixel, rSrcSizePixel );
-
- aSrcRect.Justify();
-
- if( rBmp.IsEmpty() || !aSrcRect.GetWidth() || !aSrcRect.GetHeight() || !aDestSz.Width() || !aDestSz.Height() )
- return;
-
- Bitmap aPaint( rBmp ), aMask( rMask );
- BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE;
-
- if( aMask.GetBitCount() > 1 )
- aMask.Convert( BmpConversion::N1BitThreshold );
-
- // mirrored horizontally
- if( aDestSz.Width() < 0 )
- {
- aDestSz.setWidth( -aDestSz.Width() );
- aDestPt.AdjustX( -( aDestSz.Width() - 1 ) );
- nMirrFlags |= BmpMirrorFlags::Horizontal;
- }
-
- // mirrored vertically
- if( aDestSz.Height() < 0 )
- {
- aDestSz.setHeight( -aDestSz.Height() );
- aDestPt.AdjustY( -( aDestSz.Height() - 1 ) );
- nMirrFlags |= BmpMirrorFlags::Vertical;
- }
-
- // source cropped?
- if( aSrcRect != tools::Rectangle( Point(), aPaint.GetSizePixel() ) )
- {
- aPaint.Crop( aSrcRect );
- aMask.Crop( aSrcRect );
- }
-
- // destination mirrored
- if( nMirrFlags != BmpMirrorFlags::NONE )
- {
- aPaint.Mirror( nMirrFlags );
- aMask.Mirror( nMirrFlags );
- }
-
- // we always want to have a mask
- if( aMask.IsEmpty() )
- {
- aMask = Bitmap( aSrcRect.GetSize(), 1 );
- aMask.Erase( COL_BLACK );
- }
-
- // do painting
- const tools::Long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight();
- tools::Long nX, nY; // , nWorkX, nWorkY, nWorkWidth, nWorkHeight;
- std::unique_ptr<tools::Long[]> pMapX(new tools::Long[ nSrcWidth + 1 ]);
- std::unique_ptr<tools::Long[]> pMapY(new tools::Long[ nSrcHeight + 1 ]);
- const bool bOldMap = mbMap;
-
- mbMap = false;
-
- // create forward mapping tables
- for( nX = 0; nX <= nSrcWidth; nX++ )
- pMapX[ nX ] = aDestPt.X() + FRound( static_cast<double>(aDestSz.Width()) * nX / nSrcWidth );
-
- for( nY = 0; nY <= nSrcHeight; nY++ )
- pMapY[ nY ] = aDestPt.Y() + FRound( static_cast<double>(aDestSz.Height()) * nY / nSrcHeight );
-
- // walk through all rectangles of mask
- const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel())));
- RectangleVector aRectangles;
- aWorkRgn.GetRegionRectangles(aRectangles);
-
- for (auto const& rectangle : aRectangles)
- {
- const Point aMapPt(pMapX[rectangle.Left()], pMapY[rectangle.Top()]);
- const Size aMapSz( pMapX[rectangle.Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1
- pMapY[rectangle.Bottom() + 1] - aMapPt.Y()); // same for Y
- Bitmap aBandBmp(aPaint);
-
- aBandBmp.Crop(rectangle);
- DrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp);
- }
-
- mbMap = bOldMap;
-
-}
-
// Caution: This method is nearly the same as
// void OutputDevice::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rB2DPolyPoly )
// so when changes are made here do not forget to make changes there, too