diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2012-07-25 23:50:33 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2012-07-25 23:53:42 +0200 |
commit | 085e747b6ca4148b35f37daf622a5ee79710cd66 (patch) | |
tree | 2456f839026cbea541916c423a6a772f3cd805b0 /svtools | |
parent | 8f5b707d905f84f0102d1fdf365761ca03688742 (diff) |
Fix bitmap resizing issue when using ScaleRotateCrop with BitmapEx.
Change-Id: I1fd08d94c506580ed7557066448ccb10adb9b16d
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/graphic/grfmgr2.cxx | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx index f3b6a073b9ec..dc6c3c7b8d0a 100644 --- a/svtools/source/graphic/grfmgr2.cxx +++ b/svtools/source/graphic/grfmgr2.cxx @@ -304,11 +304,11 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOutputDevice, bool isHorizontalMirrored = ( rAttributes.GetMirrorFlags() & BMP_MIRROR_HORZ ) != 0; bool isVerticalMirrored = ( rAttributes.GetMirrorFlags() & BMP_MIRROR_VERT ) != 0; - Rectangle aBitmapRectangle( aOutPointInPixels, aOutSizeInPixels ); // calculate output sizes if( !pResultBitmapEx ) { + Rectangle aBitmapRectangle( aOutPointInPixels, aOutSizeInPixels ); Rectangle aOutRect( Point(), pOutputDevice->GetOutputSizePixel() ); if( pOutputDevice->GetOutDevType() == OUTDEV_WINDOW ) @@ -332,7 +332,6 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOutputDevice, aOutRect.Top() - aBitmapRectangle.Top(), aOutRect.Right() - aBitmapRectangle.Left(), aOutRect.Bottom() - aBitmapRectangle.Top() ); - } } else @@ -352,14 +351,11 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOutputDevice, // do transformation - // #105229# Don't scale if output size equals bitmap size - // #107226# Copy through only if we're not mirroring if( !isHorizontalMirrored && !isVerticalMirrored && - aOutSizeInPixels == rBitmapSizePixels && - !nRotation) + !nRotation && + aOutSizeInPixels == rBitmapSizePixels) { - // #107226# Use original dimensions when just copying through aOutPoint = pOutputDevice->PixelToLogic( aOutPointInPixels ); aOutSize = pOutputDevice->PixelToLogic( aOutSizeInPixels ); bRet = true; @@ -374,20 +370,33 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOutputDevice, if( isHorizontalMirrored || isVerticalMirrored ) bRet = aBitmapEx.Mirror( rAttributes.GetMirrorFlags() ); - // depending on the flags, scale the image to the desired proportions - // use FAST scale if no smooth scale is desired - if( nFlags & GRFMGR_DRAW_SMOOTHSCALE) + if (nRotation) { Polygon aPoly( Rectangle( Point(), aUnrotatedSizeInPixels) ); aPoly.Rotate( Point(), nRotation ); Rectangle aNewBound( aPoly.GetBoundRect() ); - Rectangle aCropRectangle2 ( - aCropRectangle.Left() + aNewBound.Left(), - aCropRectangle.Top() + aNewBound.Top(), - aCropRectangle.Right() + aNewBound.Left(), - aCropRectangle.Bottom() + aNewBound.Top()); - bRet = aBitmapEx.ScaleCropRotate( fScaleX, fScaleY, aCropRectangle2, nRotation, COL_TRANSPARENT ); + aCropRectangle = Rectangle ( + aCropRectangle.Left() + aNewBound.Left(), + aCropRectangle.Top() + aNewBound.Top(), + aCropRectangle.Right() + aNewBound.Left(), + aCropRectangle.Bottom() + aNewBound.Top() ); + } + if( nFlags & GRFMGR_DRAW_SMOOTHSCALE) + { + bRet = aBitmapEx.ScaleCropRotate( fScaleX, fScaleY, aCropRectangle, nRotation, COL_TRANSPARENT ); + } + else + { + aCropRectangle = Rectangle ( + aCropRectangle.Left() / fScaleX, + aCropRectangle.Right() / fScaleX, + aCropRectangle.Top() / fScaleY, + aCropRectangle.Bottom() / fScaleY ); + + bRet = aBitmapEx.Crop( aCropRectangle ); + if (bRet) + bRet = aBitmapEx.Scale( fScaleX, fScaleY ); } } |