diff --git a/gfx/src/windows/nsImageWin.cpp b/gfx/src/windows/nsImageWin.cpp index 68cf3b368bd8..675d09e55827 100644 --- a/gfx/src/windows/nsImageWin.cpp +++ b/gfx/src/windows/nsImageWin.cpp @@ -1058,14 +1058,22 @@ nsImageWin :: CleanUpDDB() nsresult nsImageWin::PrintDDB(nsDrawingSurface aSurface,PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight,PRUint32 aROP) { -HDC theHDC; +HDC theHDC; +UINT palType; if (mIsOptimized == PR_TRUE){ if (mHBitmap != nsnull){ ConvertDDBtoDIB(aWidth,aHeight); ((nsDrawingSurfaceWin *)aSurface)->GetDC(&theHDC); + + if (mBHead->biBitCount == 8) { + palType = DIB_PAL_COLORS; + } else { + palType = DIB_RGB_COLORS; + } + ::StretchDIBits(theHDC, aX, aY, aWidth, aHeight, - 0, 0, mBHead->biWidth, mBHead->biHeight, mImageBits,(LPBITMAPINFO)mBHead,DIB_RGB_COLORS, aROP); + 0, 0, mBHead->biWidth, mBHead->biHeight, mImageBits,(LPBITMAPINFO)mBHead,palType, aROP); // we are finished with this, so delete it if (mImageBits != nsnull) { @@ -1090,6 +1098,7 @@ PRInt32 numbytes; BITMAP srcinfo; HBITMAP oldbits; HDC memPrDC; +UINT palType; if (mIsOptimized == PR_TRUE){ @@ -1106,7 +1115,14 @@ HDC memPrDC; // Allocate the image bits mImageBits = new unsigned char[mSizeImage]; - numbytes = ::GetDIBits(memPrDC,mHBitmap,0,srcinfo.bmHeight,mImageBits,(LPBITMAPINFO)mBHead,DIB_RGB_COLORS); + + if (mBHead->biBitCount == 8) { + palType = DIB_PAL_COLORS; + } else { + palType = DIB_RGB_COLORS; + } + + numbytes = ::GetDIBits(memPrDC,mHBitmap,0,srcinfo.bmHeight,mImageBits,(LPBITMAPINFO)mBHead,palType); ::SelectObject(memPrDC,oldbits); DeleteDC(memPrDC); }