drawinglayer/source/processor2d/vclhelperbitmaprender.cxx | 20 + drawinglayer/source/processor2d/vclhelperbitmaptransform.cxx | 141 +-------- drawinglayer/source/processor2d/vclprocessor2d.cxx | 12 filter/source/msfilter/escherex.cxx | 5 include/filter/msfilter/escherex.hxx | 1 include/vcl/bitmap.hxx | 6 sd/source/filter/eppt/epptso.cxx | 11 sd/source/ui/view/sdview3.cxx | 24 - vcl/source/gdi/bitmap3.cxx | 171 ++++------- 9 files changed, 133 insertions(+), 258 deletions(-)
New commits: commit e94baf5bcd5ceb749ff54d68287b1d37b211b535 Author: Armin Le Grand <[email protected]> Date: Wed Nov 28 13:55:37 2012 +0000 Related: #i121387# Corrected flag usages in RenderPolygonHairlinePrimitive2D (cherry picked from commit e3eebb16c90fa5c3320fa9843e3420293bec6ab2) Conflicts: drawinglayer/source/processor2d/vclprocessor2d.cxx Change-Id: I245d7ebc040580057948fdd5888f55eaca783b2a diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index bdf451e..8a2ddcc 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -451,9 +451,10 @@ namespace drawinglayer aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); // #i121387# when mirrored and rotated, avoid the GraphicManager output which has low quality - const bool bRotated(basegfx::fTools::equalZero(fRotate)); - const bool bSheared(basegfx::fTools::equalZero(fShearX)); - const bool bMirroredAndRotated(bRotated && (aScale.getX() < 0.0 || aScale.getY() < 0.0)); + const bool bRotated(!basegfx::fTools::equalZero(fRotate)); + const bool bSheared(!basegfx::fTools::equalZero(fShearX)); + const bool bMirrored(aScale.getX() < 0.0 || aScale.getY() < 0.0); + const bool bMirroredAndRotated(bRotated && bMirrored); if(!bForceUseOfOwnTransformer && !bSheared && !bMirroredAndRotated) { commit 829d31c122afe13df3463fe905fff4a9e93d13db Author: Armin Le Grand <[email protected]> Date: Wed Nov 28 12:52:24 2012 +0000 Resolves: #i121387# Corrected RenderBitmapPrimitive2D_GraphicManager... to correctly handle cases with combinations of mirroring and rotation, also changed VclProcessor2D::RenderBitmapPrimitive2D to use own bitmapEx renderer for these cases for better quality (cherry picked from commit b8cf3355071035085c705a65558cd4a6cefe8f47) Change-Id: I3f0c61db9c776299e9ee866c4e54d9c6ac431a31 diff --git a/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx b/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx index 3cd0bfb..f1aa08c 100644 --- a/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx +++ b/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx @@ -67,12 +67,28 @@ namespace drawinglayer { // if rotated, create the unrotated output rectangle for the GraphicManager paint // #118824# Caution! When mirrored, adapt transformation accordingly + // #i121387# Also need to adapt position when mirror and rotation is combined + if(bMirrorX || bMirrorY) + { + const basegfx::B2DHomMatrix aRot(basegfx::tools::createRotateB2DHomMatrix(fRotate)); + + if(bMirrorX) + { + aTranslate += aRot * basegfx::B2DVector(aScale.getX(), 0.0); + } + + if(bMirrorY) + { + aTranslate += aRot * basegfx::B2DVector(0.0, aScale.getY()); + } + } + const basegfx::B2DHomMatrix aSimpleObjectMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix( fabs(aScale.getX()), fabs(aScale.getY()), - bMirrorX ? aTranslate.getX() - fabs(aScale.getX()): aTranslate.getX(), - bMirrorY ? aTranslate.getY() - fabs(aScale.getY()): aTranslate.getY())); + aTranslate.getX(), + aTranslate.getY())); aOutlineRange.transform(aSimpleObjectMatrix); } diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 9741bc8..bdf451e 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -450,9 +450,14 @@ namespace drawinglayer double fRotate, fShearX; aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX); - if(!bForceUseOfOwnTransformer && basegfx::fTools::equalZero(fShearX)) + // #i121387# when mirrored and rotated, avoid the GraphicManager output which has low quality + const bool bRotated(basegfx::fTools::equalZero(fRotate)); + const bool bSheared(basegfx::fTools::equalZero(fShearX)); + const bool bMirroredAndRotated(bRotated && (aScale.getX() < 0.0 || aScale.getY() < 0.0)); + + if(!bForceUseOfOwnTransformer && !bSheared && !bMirroredAndRotated) { - if(!bUseGraphicManager && basegfx::fTools::equalZero(fRotate)) + if(!bUseGraphicManager && !bRotated) { RenderBitmapPrimitive2D_BitmapEx(*mpOutputDevice, aBitmapEx, aLocalTransform); } @@ -463,7 +468,7 @@ namespace drawinglayer } else { - if(!aBitmapEx.IsTransparent() && (!basegfx::fTools::equalZero(fShearX) || !basegfx::fTools::equalZero(fRotate))) + if(!aBitmapEx.IsTransparent() && (bSheared || bRotated)) { // parts will be uncovered, extend aBitmapEx with a mask bitmap const Bitmap aContent(aBitmapEx.GetBitmap()); commit c856a390abbf278a6c4c80f36c8e64d15554a1ae Author: Armin Le Grand <[email protected]> Date: Wed Nov 14 16:23:23 2012 +0000 Resolves: #i120393# Corrected paste position of objects... with geometry outside their logic definition (cherry picked from commit 658c1d82654af635bfbd6790fab2da8664d163eb) Conflicts: sd/source/ui/view/sdview3.cxx Change-Id: I4451956ab71d50e2ffec63ca17e0051d85823669 diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index 38079c5..94b2abb 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -616,8 +616,8 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper, pWorkPage->SetRectsDirty(); - // Use SnapRect, not BoundRect - Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() ); + // #i120393# Clipboard data uses full object geometry range + const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() ); maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ); maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ); @@ -780,8 +780,8 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper, if( pOwnData ) { - // Use SnapRect, not BoundRect - Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() ); + // #i120393# Clipboard data uses full object geometry range + const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() ); maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ); maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ); @@ -846,8 +846,8 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper, if( pOwnData ) { - // Use SnapRect, not BoundRect - Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() ); + // #i120393# Clipboard data uses full object geometry range + const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() ); maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ); maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ); @@ -1167,8 +1167,8 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper, pWorkPage->SetRectsDirty(); - // Use SnapRect, not BoundRect - Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() ); + // #i120393# Clipboard data uses full object geometry range + const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() ); aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ); aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ); @@ -1198,8 +1198,8 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper, pWorkPage->SetRectsDirty(); - // Use SnapRect, not BoundRect - Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() ); + // #i120393# Clipboard data uses full object geometry range + const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() ); aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ); aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ); @@ -1224,8 +1224,8 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper, pWorkPage->SetRectsDirty(); - // Use SnapRect, not BoundRect - Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() ); + // #i120393# Clipboard data uses full object geometry range + const Size aSize( pWorkPage->GetAllObjBoundRect().GetSize() ); aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 ); aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 ); commit bdfac6fdb521104f71fc28e24dfd8c9ea02a95d3 Author: Armin Le Grand <[email protected]> Date: Mon Nov 12 16:56:58 2012 +0000 Corrected bitmap scaler to not create 24bit outputs for scaling masks/alphas (cherry picked from commit 61e12761a4887b8a6bbb977996cd1ea4080d00ac) Change-Id: Ic358251ac6646b1fd8c8323171bb48958236f407 diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index eeec752..6507d5d 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -1179,6 +1179,7 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca if( bRet ) { bRet = sal_False; + const Bitmap aOriginal(*this); *this = aNewBmp; aNewBmp = Bitmap( Size( nNewWidth, nNewHeight ), 24 ); pReadAcc = AcquireReadAccess(); @@ -1249,7 +1250,7 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca if( bRet ) { - ImplAdaptBitCount(aNewBmp); + aOriginal.ImplAdaptBitCount(aNewBmp); *this = aNewBmp; } } commit d959ff60f0f014a03ecbb55b2ab6256d474f5e84 Author: Armin Le Grand <[email protected]> Date: Thu Nov 1 08:35:23 2012 +0000 Related: #i119536# removed code no longer needed after fix of that task (cherry picked from commit bcc6f1762eda8ac5290eb10b4ad47a249c9b5f51) Conflicts: sd/source/filter/eppt/epptso.cxx Change-Id: I42bce7ff99264d3bd1e3e5dbdf8eda87a05361a7 diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index 30ce35d..fa1a46b 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -2835,21 +2835,10 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a else { ImplCreateShape( ESCHER_ShpInst_PictureFrame, 0xa00, aSolverContainer ); - const Rectangle aOldRect100thmm(aRect100thmm); if ( aPropOpt.CreateGraphicProperties( mXPropSet, OUString( "GraphicURL" ), sal_False, sal_True ) ) { aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 ); - - if(aOldRect100thmm != aRect100thmm) - { - // #119536# graphic has been adapted (rotated) so that it can be saved without angle, - // adapt local values as needed - maPosition = MapPoint( ::com::sun::star::awt::Point( aRect100thmm.Left(), aRect100thmm.Top() ) ); - maSize = MapSize( ::com::sun::star::awt::Size ( aRect100thmm.GetWidth(), aRect100thmm.GetHeight() ) ); - maRect = Rectangle( Point( maPosition.X, maPosition.Y ), Size( maSize.Width, maSize.Height ) ); - mnAngle = 0; - } } } } commit 131486a9ad5d3c66911adeb4608d2d0e1d8dc31b Author: Armin Le Grand <[email protected]> Date: Wed Oct 31 16:17:35 2012 +0000 removed unused variable bSuppressRotation (cherry picked from commit b7a63f1dc7c1ddab8092f1b7b9641923aa857579) Conflicts: filter/inc/filter/msfilter/escherex.hxx Change-Id: I66b664c26d5db2dae2deea36490350d40deb3ccd diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index a517f32..f667769 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -146,7 +146,6 @@ void EscherPropertyContainer::ImplInit() nCountSize = 0; nSortBufSize = 64; bHasComplexData = sal_False; - bSuppressRotation = sal_False; pSortStruct = new EscherPropSortStruct[ nSortBufSize ]; } @@ -311,9 +310,6 @@ void EscherPropertyContainer::Commit( SvStream& rSt, sal_uInt16 nVersion, sal_uI sal_uInt32 nPropValue = pSortStruct[ i ].nPropValue; sal_uInt16 nPropId = pSortStruct[ i ].nPropId; - if ( bSuppressRotation && ( nPropId == ESCHER_Prop_Rotation ) ) - nPropValue = 0; - rSt << nPropId << nPropValue; } @@ -2336,7 +2332,6 @@ sal_Bool EscherPropertyContainer::CreateConnectorProperties( } CreateLineProperties( aXPropSet, sal_False ); bRetValue = sal_True; - bSuppressRotation = sal_False; } } } diff --git a/include/filter/msfilter/escherex.hxx b/include/filter/msfilter/escherex.hxx index d21e2f0..289cc79 100644 --- a/include/filter/msfilter/escherex.hxx +++ b/include/filter/msfilter/escherex.hxx @@ -1177,7 +1177,6 @@ class MSFILTER_DLLPUBLIC EscherPropertyContainer sal_uInt32 nCountSize; sal_Bool bHasComplexData; - sal_Bool bSuppressRotation; sal_uInt32 ImplGetColor( const sal_uInt32 rColor, sal_Bool bSwap = sal_True ); commit 9536e3cbb8b1e765b83cdb10359cca91ff80b172 Author: Armin Le Grand <[email protected]> Date: Tue Oct 30 11:02:38 2012 +0000 Resolves: #i121233# some slight corrections/enhancements (cherry picked from commit db00dfd93ac0e215a5d71e72645790918db0e734) Conflicts: vcl/inc/vcl/bitmap.hxx vcl/source/gdi/bitmap3.cxx Change-Id: I1a7817a94232b3d7f1c095dd27025e4cccea348c diff --git a/drawinglayer/source/processor2d/vclhelperbitmaptransform.cxx b/drawinglayer/source/processor2d/vclhelperbitmaptransform.cxx index 6033eb4..76ea68d 100644 --- a/drawinglayer/source/processor2d/vclhelperbitmaptransform.cxx +++ b/drawinglayer/source/processor2d/vclhelperbitmaptransform.cxx @@ -110,78 +110,14 @@ namespace drawinglayer } } - void impSmoothIndex(BitmapColor& rValue, const basegfx::B2DPoint& rSource, sal_Int32 nIntX, sal_Int32 nIntY, BitmapReadAccess& rRead) + Bitmap impTransformBitmap( + const Bitmap& rSource, + const Size aDestinationSize, + const basegfx::B2DHomMatrix& rTransform, + bool bSmooth) { - double fDeltaX(rSource.getX() - nIntX); - double fDeltaY(rSource.getY() - nIntY); - sal_Int32 nIndX(0L); - sal_Int32 nIndY(0L); - - if(fDeltaX > 0.0 && nIntX + 1L < rRead.Width()) - { - nIndX++; - } - else if(fDeltaX < 0.0 && nIntX >= 1L) - { - fDeltaX = -fDeltaX; - nIndX--; - } - - if(fDeltaY > 0.0 && nIntY + 1L < rRead.Height()) - { - nIndY++; - } - else if(fDeltaY < 0.0 && nIntY >= 1L) - { - fDeltaY = -fDeltaY; - nIndY--; - } - - if(nIndX || nIndY) - { - const double fColorToReal(1.0 / 255.0); - double fVal(rValue.GetIndex() * fColorToReal); - double fValBottom(0.0); - - if(nIndX) - { - const double fMulA(fDeltaX * fColorToReal); - double fMulB(1.0 - fDeltaX); - const BitmapColor aTopPartner(rRead.GetPixel(nIntY, nIntX + nIndX)); - - fVal = (fVal * fMulB) + (aTopPartner.GetIndex() * fMulA); - - if(nIndY) - { - fMulB *= fColorToReal; - const BitmapColor aBottom(rRead.GetPixel(nIntY + nIndY, nIntX)); - const BitmapColor aBottomPartner(rRead.GetPixel(nIntY + nIndY, nIntX + nIndX)); - - fValBottom = (aBottom.GetIndex() * fMulB) + (aBottomPartner.GetIndex() * fMulA); - } - } - - if(nIndY) - { - if(!nIndX) - { - const BitmapColor aBottom(rRead.GetPixel(nIntY + nIndY, nIntX)); - - fValBottom = aBottom.GetIndex() * fColorToReal; - } - - const double fMulB(1.0 - fDeltaY); - - fVal = (fVal * fMulB) + (fValBottom * fDeltaY); - } - - rValue.SetIndex((sal_uInt8)(fVal * 255.0)); - } - } - - void impTransformBitmap(const Bitmap& rSource, Bitmap& rDestination, const basegfx::B2DHomMatrix& rTransform, bool bSmooth) - { - BitmapWriteAccess* pWrite = rDestination.AcquireWriteAccess(); + Bitmap aDestination(aDestinationSize, 24); + BitmapWriteAccess* pWrite = aDestination.AcquireWriteAccess(); if(pWrite) { @@ -190,9 +126,9 @@ namespace drawinglayer if(pRead) { - const Size aDestinationSizePixel(rDestination.GetSizePixel()); - bool bWorkWithIndex(rDestination.GetBitCount() <= 8); - BitmapColor aOutside(pRead->GetBestMatchingColor(BitmapColor(0xff, 0xff, 0xff))); + const Size aDestinationSizePixel(aDestination.GetSizePixel()); + bool bWorkWithIndex(rSource.GetBitCount() <= 8); + BitmapColor aOutside(BitmapColor(0xff, 0xff, 0xff)); for(sal_Int32 y(0L); y < aDestinationSizePixel.getHeight(); y++) { @@ -207,29 +143,24 @@ namespace drawinglayer if(nIntY >= 0L && nIntY < aContentSizePixel.getHeight()) { + // inside pixel + BitmapColor aValue; + if(bWorkWithIndex) { - BitmapColor aValue(pRead->GetPixel(nIntY, nIntX)); - - if(bSmooth) - { - impSmoothIndex(aValue, aSourceCoor, nIntX, nIntY, *pRead); - } - - pWrite->SetPixel(y, x, aValue); + aValue = pRead->GetPaletteColor(pRead->GetPixelIndex(nIntY, nIntX)); } else { - BitmapColor aValue(pRead->GetColor(nIntY, nIntX)); - - if(bSmooth) - { - impSmoothPoint(aValue, aSourceCoor, nIntX, nIntY, *pRead); - } + aValue = pRead->GetPixel(nIntY, nIntX); + } - pWrite->SetPixel(y, x, aValue.IsIndex() ? aValue : pWrite->GetBestMatchingColor(aValue)); + if(bSmooth) + { + impSmoothPoint(aValue, aSourceCoor, nIntX, nIntY, *pRead); } + pWrite->SetPixel(y, x, aValue); continue; } } @@ -247,29 +178,10 @@ namespace drawinglayer delete pWrite; } - } - - Bitmap impCreateEmptyBitmapWithPattern(const Bitmap& rSource, const Size& aTargetSizePixel) - { - Bitmap aRetval; - BitmapReadAccess* pReadAccess = (const_cast< Bitmap& >(rSource)).AcquireReadAccess(); - if(pReadAccess) - { - if(rSource.GetBitCount() <= 8) - { - BitmapPalette aPalette(pReadAccess->GetPalette()); - aRetval = Bitmap(aTargetSizePixel, rSource.GetBitCount(), &aPalette); - } - else - { - aRetval = Bitmap(aTargetSizePixel, rSource.GetBitCount()); - } - - delete pReadAccess; - } + rSource.AdaptBitCount(aDestination); - return aRetval; + return aDestination; } } // end of anonymous namespace } // end of namespace drawinglayer @@ -283,23 +195,20 @@ namespace drawinglayer { // force destination to 24 bit, we want to smooth output const Size aDestinationSize(rCroppedRectPixel.GetSize()); - Bitmap aDestination(impCreateEmptyBitmapWithPattern(rSource.GetBitmap(), aDestinationSize)); static bool bDoSmoothAtAll(true); - impTransformBitmap(rSource.GetBitmap(), aDestination, rTransform, bDoSmoothAtAll); + const Bitmap aDestination(impTransformBitmap(rSource.GetBitmap(), aDestinationSize, rTransform, bDoSmoothAtAll)); // create mask if(rSource.IsTransparent()) { if(rSource.IsAlpha()) { - Bitmap aAlpha(impCreateEmptyBitmapWithPattern(rSource.GetAlpha().GetBitmap(), aDestinationSize)); - impTransformBitmap(rSource.GetAlpha().GetBitmap(), aAlpha, rTransform, bDoSmoothAtAll); + const Bitmap aAlpha(impTransformBitmap(rSource.GetAlpha().GetBitmap(), aDestinationSize, rTransform, bDoSmoothAtAll)); return BitmapEx(aDestination, AlphaMask(aAlpha)); } else { - Bitmap aMask(impCreateEmptyBitmapWithPattern(rSource.GetMask(), aDestinationSize)); - impTransformBitmap(rSource.GetMask(), aMask, rTransform, false); + const Bitmap aMask(impTransformBitmap(rSource.GetMask(), aDestinationSize, rTransform, false)); return BitmapEx(aDestination, aMask); } } diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index 1715022..a5388fa 100644 --- a/include/vcl/bitmap.hxx +++ b/include/vcl/bitmap.hxx @@ -342,7 +342,7 @@ public: BitmapWriteAccess& rAcc, sal_Bool bRLE4 ); SAL_DLLPRIVATE static sal_Bool ImplWriteRLE( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool bRLE4 ); - SAL_DLLPRIVATE void ImplAdaptBitCount(Bitmap& rNew); + SAL_DLLPRIVATE void ImplAdaptBitCount(Bitmap& rNew) const; SAL_DLLPRIVATE sal_Bool ImplScaleFast( const double& rScaleX, const double& rScaleY ); SAL_DLLPRIVATE sal_Bool ImplScaleInterpolate( const double& rScaleX, const double& rScaleY ); SAL_DLLPRIVATE sal_Bool ImplScaleSuper( const double& rScaleX, const double& rScaleY ); @@ -616,6 +616,10 @@ public: */ sal_Bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag = BMP_SCALE_DEFAULT ); + // Adapt the BitCount of rNew to BitCount of lolal, including grey or color paltette + // Can be used to create alpha/mask bitmaps after their processing in 24bit + void AdaptBitCount(Bitmap& rNew) const; + /** Rotate bitmap by the specified angle @param nAngle10 diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index 1ee4ce4..eeec752 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -950,7 +950,16 @@ sal_Bool Bitmap::Scale( const Size& rNewSize, sal_uInt32 nScaleFlag ) return bRet; } -void Bitmap::ImplAdaptBitCount(Bitmap& rNew) +// ------------------------------------------------------------------------ + +void Bitmap::AdaptBitCount(Bitmap& rNew) const +{ + ImplAdaptBitCount(rNew); +} + +// ------------------------------------------------------------------------ + +void Bitmap::ImplAdaptBitCount(Bitmap& rNew) const { // aNew is the result of some operation; adapt it's BitCount to the original (this) if(GetBitCount() != rNew.GetBitCount()) @@ -1109,73 +1118,52 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca pLutFrac[ nX ] = (long) ( fTemp * 1024. ); } - if( pReadAcc->HasPalette() ) + for( nY = 0L; nY < nHeight; nY++ ) { - for( nY = 0L; nY < nHeight; nY++ ) + if( 1 == nWidth ) { - if( 1 == nWidth ) + if( pReadAcc->HasPalette() ) { aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, 0 ) ); - - for( nX = 0L; nX < nNewWidth; nX++ ) - pWriteAcc->SetPixel( nY, nX, aCol0 ); } else { - for( nX = 0L; nX < nNewWidth; nX++ ) - { - nTemp = pLutInt[ nX ]; - - aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp++ ) ); - aCol1 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp ) ); - - nTemp = pLutFrac[ nX ]; - - lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() ); - lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() ); - lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() ); - - aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); - aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); - aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); + aCol0 = pReadAcc->GetPixel( nY, 0 ); + } - pWriteAcc->SetPixel( nY, nX, aCol0 ); - } + for( nX = 0L; nX < nNewWidth; nX++ ) + { + pWriteAcc->SetPixel( nY, nX, aCol0 ); } } - } - else - { - for( nY = 0L; nY < nHeight; nY++ ) + else { - if( 1 == nWidth ) + for( nX = 0L; nX < nNewWidth; nX++ ) { - aCol0 = pReadAcc->GetPixel( nY, 0 ); + nTemp = pLutInt[ nX ]; - for( nX = 0L; nX < nNewWidth; nX++ ) - pWriteAcc->SetPixel( nY, nX, aCol0 ); - } - else - { - for( nX = 0L; nX < nNewWidth; nX++ ) + if( pReadAcc->HasPalette() ) + { + aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp++ ) ); + aCol1 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nTemp ) ); + } + else { - nTemp = pLutInt[ nX ]; - aCol0 = pReadAcc->GetPixel( nY, nTemp++ ); aCol1 = pReadAcc->GetPixel( nY, nTemp ); + } - nTemp = pLutFrac[ nX ]; + nTemp = pLutFrac[ nX ]; - lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() ); - lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() ); - lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() ); + lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() ); + lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() ); + lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() ); - aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); - aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); - aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); + aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); + aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); + aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); - pWriteAcc->SetPixel( nY, nX, aCol0 ); - } + pWriteAcc->SetPixel( nY, nX, aCol0 ); } } } @@ -1191,10 +1179,9 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca if( bRet ) { bRet = sal_False; - ImplAdaptBitCount(aNewBmp); - ImplAssignWithSize( aNewBmp ); - pReadAcc = AcquireReadAccess(); + *this = aNewBmp; aNewBmp = Bitmap( Size( nNewWidth, nNewHeight ), 24 ); + pReadAcc = AcquireReadAccess(); pWriteAcc = aNewBmp.AcquireWriteAccess(); if( pReadAcc && pWriteAcc ) @@ -1214,73 +1201,40 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca pLutFrac[ nY ] = (long) ( fTemp * 1024. ); } - if( pReadAcc->HasPalette() ) + // after 1st step, bitmap *is* 24bit format (see above) + OSL_ENSURE(!pReadAcc->HasPalette(), "OOps, somehow ImplScaleInterpolate in-between format has palette, should not happen (!)"); + + for( nX = 0L; nX < nNewWidth; nX++ ) { - for( nX = 0L; nX < nNewWidth; nX++ ) + if( 1 == nHeight ) { - if( 1 == nHeight ) - { - aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( 0, nX ) ); + aCol0 = pReadAcc->GetPixel( 0, nX ); - for( nY = 0L; nY < nNewHeight; nY++ ) - pWriteAcc->SetPixel( nY, nX, aCol0 ); - } - else + for( nY = 0L; nY < nNewHeight; nY++ ) { - for( nY = 0L; nY < nNewHeight; nY++ ) - { - nTemp = pLutInt[ nY ]; - - aCol0 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nTemp++, nX ) ); - aCol1 = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nTemp, nX ) ); - - nTemp = pLutFrac[ nY ]; - - lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() ); - lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() ); - lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() ); - - aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); - aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); - aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); - - pWriteAcc->SetPixel( nY, nX, aCol0 ); - } + pWriteAcc->SetPixel( nY, nX, aCol0 ); } } - } - else - { - for( nX = 0L; nX < nNewWidth; nX++ ) + else { - if( 1 == nHeight ) - { - aCol0 = pReadAcc->GetPixel( 0, nX ); - - for( nY = 0L; nY < nNewHeight; nY++ ) - pWriteAcc->SetPixel( nY, nX, aCol0 ); - } - else + for( nY = 0L; nY < nNewHeight; nY++ ) { - for( nY = 0L; nY < nNewHeight; nY++ ) - { - nTemp = pLutInt[ nY ]; + nTemp = pLutInt[ nY ]; - aCol0 = pReadAcc->GetPixel( nTemp++, nX ); - aCol1 = pReadAcc->GetPixel( nTemp, nX ); + aCol0 = pReadAcc->GetPixel( nTemp++, nX ); + aCol1 = pReadAcc->GetPixel( nTemp, nX ); - nTemp = pLutFrac[ nY ]; + nTemp = pLutFrac[ nY ]; - lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() ); - lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() ); - lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() ); + lXR1 = aCol1.GetRed() - ( lXR0 = aCol0.GetRed() ); + lXG1 = aCol1.GetGreen() - ( lXG0 = aCol0.GetGreen() ); + lXB1 = aCol1.GetBlue() - ( lXB0 = aCol0.GetBlue() ); - aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); - aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); - aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); + aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); + aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); + aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); - pWriteAcc->SetPixel( nY, nX, aCol0 ); - } + pWriteAcc->SetPixel( nY, nX, aCol0 ); } } } @@ -1296,13 +1250,15 @@ sal_Bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rSca if( bRet ) { ImplAdaptBitCount(aNewBmp); - ImplAssignWithSize( aNewBmp ); + *this = aNewBmp; } } } if( !bRet ) + { bRet = ImplScaleFast( rScaleX, rScaleY ); + } return bRet; } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
