[Libreoffice-commits] core.git: Branch 'aoo/trunk' - vcl/source

Herbert Dürr hdu at apache.org
Mon Jul 22 03:16:05 PDT 2013


 vcl/source/gdi/salmisc.cxx |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit ec3d48418f1cbad40153b3e4fdc2497ebf0e7d59
Author: Herbert Dürr <hdu at apache.org>
Date:   Mon Jul 22 09:50:08 2013 +0000

    #i122796# fix half-pixel offset in StretchAndConvert() image scaling

diff --git a/vcl/source/gdi/salmisc.cxx b/vcl/source/gdi/salmisc.cxx
index 817aa90..7b93189 100644
--- a/vcl/source/gdi/salmisc.cxx
+++ b/vcl/source/gdi/salmisc.cxx
@@ -429,12 +429,12 @@ BitmapBuffer* StretchAndConvert(
     }
 
     // horizontal mapping table
-    if( nDstDX != nSrcDX )
+    if( (nDstDX != nSrcDX) && (nDstDX != 0) )
     {
-        const double fFactorX = ( nDstDX > 1 ) ? (double) ( nSrcDX - 1 ) / ( nDstDX - 1 ) : 0.0;
+        const double fFactorX = (double)nSrcDX / nDstDX;
 
         for( i = 0L; i < nDstDX; i++ )
-            pMapX[ i ] = nSrcX + FRound( i * fFactorX );
+            pMapX[ i ] = nSrcX + static_cast<int>( i * fFactorX );
     }
     else
     {
@@ -443,12 +443,12 @@ BitmapBuffer* StretchAndConvert(
     }
 
     // vertical mapping table
-    if( nDstDY != nSrcDY )
+    if( (nDstDY != nSrcDY) && (nDstDY != 0) )
     {
-        const double fFactorY = ( nDstDY > 1 ) ? (double) ( nSrcDY - 1 ) / ( nDstDY - 1 ) : 0.0;
+        const double fFactorY = (double)nSrcDY / nDstDY;
 
         for( i = 0L; i < nDstDY; i++ )
-            pMapY[ i ] = nSrcY + FRound( i * fFactorY );
+            pMapY[ i ] = nSrcY + static_cast<int>( i * fFactorY );
     }
     else
     {


More information about the Libreoffice-commits mailing list