You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by hd...@apache.org on 2013/07/22 11:50:09 UTC

svn commit: r1505643 - /openoffice/trunk/main/vcl/source/gdi/salmisc.cxx

Author: hdu
Date: Mon Jul 22 09:50:08 2013
New Revision: 1505643

URL: http://svn.apache.org/r1505643
Log:
#i122796# fix half-pixel offset in StretchAndConvert() image scaling

Modified:
    openoffice/trunk/main/vcl/source/gdi/salmisc.cxx

Modified: openoffice/trunk/main/vcl/source/gdi/salmisc.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/vcl/source/gdi/salmisc.cxx?rev=1505643&r1=1505642&r2=1505643&view=diff
==============================================================================
--- openoffice/trunk/main/vcl/source/gdi/salmisc.cxx (original)
+++ openoffice/trunk/main/vcl/source/gdi/salmisc.cxx Mon Jul 22 09:50:08 2013
@@ -428,13 +428,13 @@ BitmapBuffer* StretchAndConvert( 
         return NULL;
     }
     
-    // horizontal mapping table
-	if( nDstDX != nSrcDX )
+	// horizontal mapping table
+	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
 	{