diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2021-09-03 18:55:08 +1000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-09-08 10:11:42 +0200 |
commit | 6d6c0e2c35186323bb5af35f5a58a2c9d9baa1ed (patch) | |
tree | 3d92d4a0adacc9b16444f4051ebc79f26cc738eb /vcl/source/outdev/bitmap.cxx | |
parent | f83d1b824c1abd07d24318adda6c876b9471ccec (diff) |
vcl: migrate GetDownsampledBitmap() from OutputDevice to vcl::bitmap
Change-Id: Iee6caa8292472a3acca66d670a113b701f4b637e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121581
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source/outdev/bitmap.cxx')
-rw-r--r-- | vcl/source/outdev/bitmap.cxx | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 5466340c2bfe..6f548cbfc7a3 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -170,74 +170,6 @@ void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize, } } -Bitmap OutputDevice::GetDownsampledBitmap( const Size& rDstSizeTwip, - const Point& rSrcPt, const Size& rSrcSz, - const Bitmap& rBmp, tools::Long nMaxBmpDPIX, tools::Long nMaxBmpDPIY ) -{ - Bitmap aBmp( rBmp ); - - if( !aBmp.IsEmpty() ) - { - const tools::Rectangle aBmpRect( Point(), aBmp.GetSizePixel() ); - tools::Rectangle aSrcRect( rSrcPt, rSrcSz ); - - // do cropping if necessary - if( aSrcRect.Intersection( aBmpRect ) != aBmpRect ) - { - if( !aSrcRect.IsEmpty() ) - aBmp.Crop( aSrcRect ); - else - aBmp.SetEmpty(); - } - - if( !aBmp.IsEmpty() ) - { - // do downsampling if necessary - // #103209# Normalize size (mirroring has to happen outside of this method) - Size aDstSizeTwip(std::abs(rDstSizeTwip.Width()), std::abs(rDstSizeTwip.Height())); - - const Size aBmpSize( aBmp.GetSizePixel() ); - const double fBmpPixelX = aBmpSize.Width(); - const double fBmpPixelY = aBmpSize.Height(); - const double fMaxPixelX - = o3tl::convert<double>(aDstSizeTwip.Width(), o3tl::Length::twip, o3tl::Length::in) - * nMaxBmpDPIX; - const double fMaxPixelY - = o3tl::convert<double>(aDstSizeTwip.Height(), o3tl::Length::twip, o3tl::Length::in) - * nMaxBmpDPIY; - - // check, if the bitmap DPI exceeds the maximum DPI (allow 4 pixel rounding tolerance) - if( ( ( fBmpPixelX > ( fMaxPixelX + 4 ) ) || - ( fBmpPixelY > ( fMaxPixelY + 4 ) ) ) && - ( fBmpPixelY > 0.0 ) && ( fMaxPixelY > 0.0 ) ) - { - // do scaling - Size aNewBmpSize; - const double fBmpWH = fBmpPixelX / fBmpPixelY; - const double fMaxWH = fMaxPixelX / fMaxPixelY; - - if( fBmpWH < fMaxWH ) - { - aNewBmpSize.setWidth( FRound( fMaxPixelY * fBmpWH ) ); - aNewBmpSize.setHeight( FRound( fMaxPixelY ) ); - } - else if( fBmpWH > 0.0 ) - { - aNewBmpSize.setWidth( FRound( fMaxPixelX ) ); - aNewBmpSize.setHeight( FRound( fMaxPixelX / fBmpWH) ); - } - - if( aNewBmpSize.Width() && aNewBmpSize.Height() ) - aBmp.Scale( aNewBmpSize ); - else - aBmp.SetEmpty(); - } - } - } - - return aBmp; -} - Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const { Bitmap aBmp; |