From f98b66a3df376788a30cd885bea2716b5c37a3be Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Thu, 16 Jul 1998 22:18:36 +0000 Subject: [PATCH] Fixed Init() to compute the mask row size correctly --- gfx/src/windows/nsImageWin.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gfx/src/windows/nsImageWin.cpp b/gfx/src/windows/nsImageWin.cpp index 5cad2803b054..b3d9b687d78c 100644 --- a/gfx/src/windows/nsImageWin.cpp +++ b/gfx/src/windows/nsImageWin.cpp @@ -79,22 +79,25 @@ nsresult nsImageWin :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMa if (aMaskRequirements != nsMaskRequirements_kNoMask) { - PRInt32 sizeMask; - if (nsMaskRequirements_kNeeds1Bit == aMaskRequirements) { - sizeMask = (aWidth + 7) / 8 * aHeight; + mARowBytes = (aWidth + 7) / 8; + mAlphaDepth = 1; } else { NS_ASSERTION(nsMaskRequirements_kNeeds8Bit == aMaskRequirements, "unexpected mask depth"); - sizeMask = aWidth * aHeight; + mARowBytes = aWidth; + mAlphaDepth = 8; } + // 32-bit align each row + mARowBytes = (mARowBytes + 3) & ~0x3; + + mAlphaBits = new unsigned char[mARowBytes * aHeight]; mAlphaWidth = aWidth; mAlphaWidth = aHeight; - mAlphaBits = new unsigned char[sizeMask]; } else {