From f3cd9831d01d45809f8df58a332960b60ad22ebd Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Wed, 16 Jan 2002 03:16:01 +0000 Subject: [PATCH] Fixes round off error for scaling and fixes to var names Bug 120072 r=dcone sr=attinasi --- gfx/src/windows/nsImageWin.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gfx/src/windows/nsImageWin.cpp b/gfx/src/windows/nsImageWin.cpp index 5effb2393bff..47277a34630e 100644 --- a/gfx/src/windows/nsImageWin.cpp +++ b/gfx/src/windows/nsImageWin.cpp @@ -684,8 +684,8 @@ NS_IMETHODIMP nsImageWin::DrawTile(nsIRenderingContext &aContext, PRInt32 - destScaledWidth = (int) (mBHead->biWidth*scale), - destScaledHeight = (int) (mBHead->biHeight*scale); + destScaledWidth = PR_MAX(int(mBHead->biWidth*scale), 1), + destScaledHeight = PR_MAX(int(mBHead->biHeight*scale), 1); PRInt32 validX = 0, @@ -698,20 +698,20 @@ NS_IMETHODIMP nsImageWin::DrawTile(nsIRenderingContext &aContext, // has been validated. if (mDecodedY2 < mBHead->biHeight) { validHeight = mDecodedY2 - mDecodedY1; - destScaledHeight = (int)(validHeight*scale); + destScaledHeight = PR_MAX(int(validHeight*scale), 1); } if (mDecodedX2 < mBHead->biWidth) { validWidth = mDecodedX2 - mDecodedX1; - destScaledHeight = (int)(validWidth*scale); + destScaledWidth = PR_MAX(int(validWidth*scale), 1); } if (mDecodedY1 > 0) { validHeight -= mDecodedY1; - destScaledHeight = (int)(validHeight*scale); + destScaledHeight = PR_MAX(int(validHeight*scale), 1); validY = mDecodedY1; } if (mDecodedX1 > 0) { validWidth -= mDecodedX1; - destScaledHeight = (int)(validWidth*scale); + destScaledWidth = PR_MAX(int(validWidth*scale), 1); validX = mDecodedX1; } @@ -724,8 +724,8 @@ NS_IMETHODIMP nsImageWin::DrawTile(nsIRenderingContext &aContext, // this is the width and height of the image in pixels // we need to map this to the pixel height of the device - nscoord imageScaledWidth = (int)(mBHead->biWidth*scale); - nscoord imageScaledHeight = (int)(mBHead->biHeight*scale); + nscoord imageScaledWidth = PR_MAX(int(mBHead->biWidth*scale), 1); + nscoord imageScaledHeight = PR_MAX(int(mBHead->biHeight*scale), 1); nscoord tileWidth = aTileRect.width; nscoord tileHeight = aTileRect.height;