[Libreoffice-commits] .: svtools/source vcl/inc vcl/source

2012-09-02 Thread Libreoffice Gerrit user
 svtools/source/graphic/grfmgr2.cxx |  726 ++---
 vcl/inc/vcl/bitmap.hxx |   18 
 vcl/inc/vcl/bitmapex.hxx   |5 
 vcl/source/gdi/bitmap3.cxx |  233 ---
 vcl/source/gdi/bitmapex.cxx|   56 --
 5 files changed, 613 insertions(+), 425 deletions(-)

New commits:
commit 4b161067d46ddd48b4602ccdcc4d1b2545e2ac83
Author: Tomaž Vajngerl 
Date:   Sun Sep 2 17:23:03 2012 +0200

Stepwise rebuild bitmap rendering from scratch to avoid rendering bugs.

Bitmap rendering was rebuild from the original state and checked for
rendering bugs at every change. Currently the implementation supports
scaling by averagin for RGB channels an for alpha channel in some
cases. For scaling factor > 0.6, the original bilinear scaling is
used. Implementation is currently still in "outdev2" but is decoupled
and will be moved to its proper place into "bitmap" and "bitmapex".

Change-Id: I6feb744712956a92d6140d079dc3a85ee8511930

diff --git a/svtools/source/graphic/grfmgr2.cxx 
b/svtools/source/graphic/grfmgr2.cxx
index 2cc7ae3..299f883 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -46,6 +46,7 @@
 
 #define WATERMARK_LUM_OFFSET50
 #define WATERMARK_CON_OFFSET-70
+#define MAP( cVal0, cVal1, nFrac )  
((sal_uInt8)long)(cVal0)<<20L)+nFrac*((long)(cVal1)-(cVal0)))>>20L))
 
 // --
 // - GraphicManager -
@@ -264,172 +265,659 @@ sal_Bool GraphicManager::ImplDraw( OutputDevice* pOut, 
const Point& rPt,
 return bRet;
 }
 
-sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* pOutputDevice,
-   const Point& rPoint, const Size& rSize,
-   const BitmapEx& rBitmapEx, const 
GraphicAttr& rAttributes,
-   const sal_uLong nFlags, BitmapEx* 
pResultBitmapEx )
+sal_Bool ImplCreateRotatedScaled( const BitmapEx& rBmpEx, const GraphicAttr& 
rAttributes,
+sal_uInt16 nRot10, const Size& rUnrotatedSzPix,
+long nStartX, long nEndX, long nStartY, long 
nEndY,
+BitmapEx& rOutBmpEx )
 {
-boolbRet = false;
+const long  aUnrotatedWidth  = rUnrotatedSzPix.Width();
+const long  aUnrotatedHeight = rUnrotatedSzPix.Height();
+const long  aBitmapWidth  = rBmpEx.GetSizePixel().Width();
+const long  aBitmapHeight = rBmpEx.GetSizePixel().Height();
 
-Point   aUnrotatedPointInPixels( pOutputDevice->LogicToPixel( rPoint ) 
);
-SizeaUnrotatedSizeInPixels(  pOutputDevice->LogicToPixel( rSize ) 
);
+longnX, nY, nTmpX, nTmpY, nTmpFX, nTmpFY, nTmp;
+double  fTmp;
 
-if( aUnrotatedSizeInPixels.Width() <= 0  || 
aUnrotatedSizeInPixels.Height() <= 0)
-return false;
+boolbHMirr = ( rAttributes.GetMirrorFlags() & BMP_MIRROR_HORZ ) != 0;
+boolbVMirr = ( rAttributes.GetMirrorFlags() & BMP_MIRROR_VERT ) != 0;
+
+long*   pMapIX = new long[ aUnrotatedWidth ];
+long*   pMapFX = new long[ aUnrotatedWidth ];
+long*   pMapIY = new long[ aUnrotatedHeight ];
+long*   pMapFY = new long[ aUnrotatedHeight ];
+
+const double fScaleX = ( aUnrotatedWidth  - 1 ) / (double) ( aBitmapWidth  
- 1 );
+const double fScaleY = ( aUnrotatedHeight - 1 ) / (double) ( aBitmapHeight 
- 1 );
 
-Point   aOutPointInPixels;
-SizeaOutSizeInPixels;
-BitmapExaBitmapEx( rBitmapEx );
-int nRotation = rAttributes.GetRotation() % 3600;
+const double fRevScaleX = 1.0 / fScaleX;
+const double fRevScaleY = 1.0 / fScaleY;
 
-if( nRotation != 0 )
+int x,y;
+
+// create horizontal mapping table
+for( x = 0, nTmpX = aBitmapWidth - 1L, nTmp = aBitmapWidth - 2L; x < 
aUnrotatedWidth; x++ )
 {
-Polygon aPoly( Rectangle( rPoint, rSize ) );
-aPoly.Rotate( rPoint, nRotation );
-const Rectangle aRotationBoundRect( aPoly.GetBoundRect() );
-aOutPointInPixels = pOutputDevice->LogicToPixel( 
aRotationBoundRect.TopLeft() );
-aOutSizeInPixels  = pOutputDevice->LogicToPixel( 
aRotationBoundRect.GetSize() );
+fTmp = x * fRevScaleX;
+
+if( bHMirr )
+fTmp = nTmpX - fTmp;
+
+pMapIX[ x ] = MinMax( fTmp, 0, nTmp );
+pMapFX[ x ] = (long) ( ( fTmp - pMapIX[ x ] ) * 1048576.0 );
 }
-else
+
+// create vertical mapping table
+for( y = 0, nTmpY = aBitmapHeight - 1L, nTmp = aBitmapHeight - 2L; y < 
aUnrotatedHeight; y++ )
 {
-aOutPointInPixels = aUnrotatedPointInPixels;
-aOutSizeInPixels  = aUnrotatedSizeInPixels;
+fTmp = y * fRevScaleY;
+
+if( bVMirr )
+fTmp = nTmpY - fTmp;
+
+pMapIY[ y ] = MinMax( fTmp, 0, nTmp );
+pMapFY[ y ] = (long) ( ( fTmp - pMapIY[ y ] ) * 1048576.0 );
 }
 
-Point   aOutPoint;
-Size

[Libreoffice-commits] .: svtools/source vcl/inc vcl/source

2012-08-14 Thread Tomaž Vajngerl
 svtools/source/graphic/grfmgr2.cxx |   60 +--
 vcl/inc/vcl/alpha.hxx  |  187 ++---
 vcl/source/gdi/alpha.cxx   |   57 ++-
 vcl/source/gdi/bitmap3.cxx |6 -
 vcl/source/gdi/bitmapex.cxx|   53 ++
 5 files changed, 191 insertions(+), 172 deletions(-)

New commits:
commit 42801a0e690a63c3a94b1d8256b6c7cd64856bd2
Author: Tomaž Vajngerl 
Date:   Tue Aug 14 20:39:14 2012 +0200

Fix transparent bitmap rendering.

Convert transparent mask to 8bit-grey after scale/rotate/crop
transformation. Use correct perspective at rendering.

Change-Id: I80b19d7bec880b0c58709c7c5bee6199cbc815c9

diff --git a/svtools/source/graphic/grfmgr2.cxx 
b/svtools/source/graphic/grfmgr2.cxx
index dc6c3c7..f738998 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -270,43 +270,43 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* 
pOutputDevice,
const sal_uLong nFlags, BitmapEx* 
pResultBitmapEx )
 {
 boolbRet = false;
-Point   aOutPointInPixels;
-SizeaOutSizeInPixels;
-int nRotation = rAttributes.GetRotation() % 3600;
 
 Point   aUnrotatedPointInPixels( pOutputDevice->LogicToPixel( rPoint ) 
);
 SizeaUnrotatedSizeInPixels(  pOutputDevice->LogicToPixel( rSize ) 
);
 
-BitmapExaBitmapEx( rBitmapEx );
-
-if( !aUnrotatedSizeInPixels.Width() || !aUnrotatedSizeInPixels.Height() )
+if( aUnrotatedSizeInPixels.Width() <= 0  || 
aUnrotatedSizeInPixels.Height() <= 0)
 return false;
 
-if( nRotation )
+Point   aOutPointInPixels;
+SizeaOutSizeInPixels;
+BitmapExaBitmapEx( rBitmapEx );
+int nRotation = rAttributes.GetRotation() % 3600;
+
+if( nRotation != 0 )
 {
 Polygon aPoly( Rectangle( rPoint, rSize ) );
 aPoly.Rotate( rPoint, nRotation );
 const Rectangle aRotationBoundRect( aPoly.GetBoundRect() );
 aOutPointInPixels = pOutputDevice->LogicToPixel( 
aRotationBoundRect.TopLeft() );
-aOutSizeInPixels = pOutputDevice->LogicToPixel( 
aRotationBoundRect.GetSize() );
+aOutSizeInPixels  = pOutputDevice->LogicToPixel( 
aRotationBoundRect.GetSize() );
 }
 else
 {
 aOutPointInPixels = aUnrotatedPointInPixels;
-aOutSizeInPixels = aUnrotatedSizeInPixels;
+aOutSizeInPixels  = aUnrotatedSizeInPixels;
 }
 
 Point   aOutPoint;
 SizeaOutSize;
 
 const Size& rBitmapSizePixels = rBitmapEx.GetSizePixel();
-Rectangle   aCropRectangle(-1, -1, -1, -1);
+Rectangle   aCropRectangle(0, 0, 0, 0);
+
 boolisHorizontalMirrored = ( rAttributes.GetMirrorFlags() & 
BMP_MIRROR_HORZ ) != 0;
 boolisVerticalMirrored   = ( rAttributes.GetMirrorFlags() & 
BMP_MIRROR_VERT ) != 0;
 
-
 // calculate output sizes
-if( !pResultBitmapEx )
+if( true || !pResultBitmapEx )
 {
 Rectangle aBitmapRectangle( aOutPointInPixels, aOutSizeInPixels );
 Rectangle aOutRect( Point(), pOutputDevice->GetOutputSizePixel() );
@@ -316,9 +316,7 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* 
pOutputDevice,
 const Region aPaintRegion( ( (Window*) pOutputDevice 
)->GetPaintRegion() );
 
 if( !aPaintRegion.IsNull() )
-{
 aOutRect.Intersection( pOutputDevice->LogicToPixel( 
aPaintRegion.GetBoundRect() ) );
-}
 }
 aOutRect.Intersection( aBitmapRectangle );
 
@@ -346,31 +344,28 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* 
pOutputDevice,
 }
 
 
-if( aCropRectangle.GetWidth() <= 0 && aCropRectangle.GetHeight() <= 0)
+if( aCropRectangle.GetWidth() <= 0 && aCropRectangle.GetHeight() <= 0 )
 return false;
 
 // do transformation
-
 if( !isHorizontalMirrored &&
 !isVerticalMirrored &&
 !nRotation &&
 aOutSizeInPixels == rBitmapSizePixels)
 {
+// simple copy thorugh
 aOutPoint = pOutputDevice->PixelToLogic( aOutPointInPixels );
 aOutSize = pOutputDevice->PixelToLogic( aOutSizeInPixels );
 bRet = true;
 }
 else
 {
-// calculate scaling factors
-double fScaleX = aUnrotatedSizeInPixels.Width()  / (double) 
rBitmapSizePixels.Width();
-double fScaleY = aUnrotatedSizeInPixels.Height() / (double) 
rBitmapSizePixels.Height();
-
 // mirror the image - this should not impact the picture dimenstions
 if( isHorizontalMirrored || isVerticalMirrored )
 bRet = aBitmapEx.Mirror( rAttributes.GetMirrorFlags() );
 
-if (nRotation)
+// prepare rotation if needed
+if (nRotation != 0)
 {
 Polygon aPoly( Rectangle( Point(), aUnrotatedSizeInPixels) );
 aPoly.Rotate( Point(), nRotation );
@@ -382,7 +377,12 @@ sal_Bool Graphi

[Libreoffice-commits] .: svtools/source vcl/inc vcl/source

2012-07-25 Thread Tomaž Vajngerl
 svtools/source/graphic/grfmgr2.cxx |   41 ---
 vcl/inc/vcl/bitmapex.hxx   |2 
 vcl/source/gdi/bitmap3.cxx |  191 ++---
 vcl/source/gdi/bitmapex.cxx|   15 +-
 4 files changed, 47 insertions(+), 202 deletions(-)

New commits:
commit 085e747b6ca4148b35f37daf622a5ee79710cd66
Author: Tomaž Vajngerl 
Date:   Wed Jul 25 23:50:33 2012 +0200

Fix bitmap resizing issue when using ScaleRotateCrop with BitmapEx.

Change-Id: I1fd08d94c506580ed7557066448ccb10adb9b16d

diff --git a/svtools/source/graphic/grfmgr2.cxx 
b/svtools/source/graphic/grfmgr2.cxx
index f3b6a07..dc6c3c7 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -304,11 +304,11 @@ sal_Bool GraphicManager::ImplCreateOutput( OutputDevice* 
pOutputDevice,
 boolisHorizontalMirrored = ( rAttributes.GetMirrorFlags() & 
BMP_MIRROR_HORZ ) != 0;
 boolisVerticalMirrored   = ( 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 );
 }
 }
 
diff --git a/vcl/inc/vcl/bitmapex.hxx b/vcl/inc/vcl/bitmapex.hxx
index a29c271..437c70a 100644
--- a/vcl/inc/vcl/bitmapex.hxx
+++ b/vcl/inc/vcl/bitmapex.hxx
@@ -60,7 +60,7 @@ private:
 SizeaBitmapSize;
 Color   aTransparentColor;
 TransparentType eTransparent;
-sal_BoolbAlpha;
+sal_BoolbAlpha;
 
 public:
 
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index b1a028c..edae9e1 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap

[Libreoffice-commits] .: svtools/source vcl/inc vcl/source

2012-07-06 Thread Noel Power
 svtools/source/brwbox/ebbcontrols.cxx |   24 +++-
 vcl/inc/vcl/button.hxx|   15 +--
 vcl/source/control/button.cxx |   18 --
 3 files changed, 44 insertions(+), 13 deletions(-)

New commits:
commit a1345cd93a57ec7d9352f2c71ec2664332ce5e76
Author: Noel Power 
Date:   Fri Jul 6 11:19:57 2012 +0100

fdo#51336 - change vcl checkbox no-label behaviour

Change-Id: I352c6041cc520dc76c302190dcf3a6945f5ac85f

diff --git a/svtools/source/brwbox/ebbcontrols.cxx 
b/svtools/source/brwbox/ebbcontrols.cxx
index 1d7b025..b0ab801 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -253,6 +253,28 @@ namespace svt
 //= CheckBoxControl
 //==
 //--
+
+class CBCntrlTriState : public TriStateBox
+{
+CBCntrlTriState( const CBCntrlTriState & );
+CBCntrlTriState& operator= ( const CBCntrlTriState & );
+protected:
+virtual void ImplHandleHoriAlign( const Point& rPos, const Size& rSize,
+const Size& rImageSize, Rectangle& 
rStateRect )
+{
+WinBits nWinStyle = GetStyle();
+if ( nWinStyle & WB_CENTER )
+rStateRect.Left() = 
rPos.X()+((rSize.Width()-rImageSize.Width())/2);
+else if ( nWinStyle & WB_RIGHT )
+rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width();
+else
+rStateRect.Left() = rPos.X();
+}
+public:
+CBCntrlTriState( Window* pParent, WinBits nStyle = 0 ) : TriStateBox( 
pParent, nStyle ) {}
+CBCntrlTriState( Window* pParent, const ResId& rResId ) : TriStateBox( 
pParent, rResId ) {}
+};
+
 CheckBoxControl::CheckBoxControl(Window* pParent, WinBits nWinStyle)
:Control(pParent, nWinStyle)
 {
@@ -267,7 +289,7 @@ namespace svt
 
 EnableChildTransparentMode();
 
-pBox = new TriStateBox(this,WB_CENTER|WB_VCENTER);
+pBox = new CBCntrlTriState(this,WB_CENTER|WB_VCENTER);
 pBox->EnableChildTransparentMode();
 pBox->SetPaintTransparent( sal_True );
 pBox->SetClickHdl( LINK( this, CheckBoxControl, OnClick ) );
diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx
index 51b6034..64f7581 100644
--- a/vcl/inc/vcl/button.hxx
+++ b/vcl/inc/vcl/button.hxx
@@ -401,7 +401,6 @@ public:
 
 class VCL_DLLPUBLIC CheckBox : public Button
 {
-private:
 Rectangle   maStateRect;
 Rectangle   maMouseRect;
 TriStatemeState;
@@ -420,7 +419,7 @@ private:
 SAL_DLLPRIVATE void ImplDrawCheckBox( bool bLayout = false );
 SAL_DLLPRIVATE long ImplGetImageToTextDistance() const;
 SAL_DLLPRIVATE Size ImplGetCheckImageSize() const;
-
+private:
 // Copy assignment is forbidden and not implemented.
 SAL_DLLPRIVATE  CheckBox(const CheckBox &);
 SAL_DLLPRIVATE  CheckBox& operator= (const CheckBox &);
@@ -428,15 +427,19 @@ private:
 protected:
 using Control::ImplInitSettings;
 using Window::ImplInit;
+// allows the behaviour of horizontal placement of the checbox image to be
+// overridden.
+virtual void ImplHandleHoriAlign( const Point& rPos, const Size& rSize,
+const Size& rImageSize, Rectangle& 
rStateRect );
 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
-SAL_DLLPRIVATE virtual void FillLayoutData() const;
-SAL_DLLPRIVATE virtual const Font&
+   virtual void FillLayoutData() const;
+   virtual const Font&
 GetCanonicalFont( const StyleSettings& _rStyle 
) const;
-SAL_DLLPRIVATE virtual const Color&
+   virtual const Color&
 GetCanonicalTextColor( const StyleSettings& 
_rStyle ) const;
 
-SAL_DLLPRIVATE virtual void ImplDrawCheckBoxState();
+   virtual void ImplDrawCheckBoxState();
 SAL_DLLPRIVATE const Rectangle& GetStateRect() const { return maStateRect; 
}
 SAL_DLLPRIVATE const Rectangle& GetMouseRect() const { return maMouseRect; 
}
 public:
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 6d5a8f9..e3ed723 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -3251,12 +3251,9 @@ void CheckBox::ImplDraw( OutputDevice* pDev, sal_uLong 
nDrawFlags,
 }
 else
 {
-if ( nWinStyle & WB_CENTER )
-rStateRect.Left() = 
rPos.X()+((rSize.Width()-rImageSize.Width())/2);
-else if ( nWinStyle & WB_RIGHT )
-rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width();
-else
-rStateRect.Left()