From e7baa01f69bb9447c641c57a33f9e5f36d6d32cf Mon Sep 17 00:00:00 2001 From: rods Date: Fri, 19 Jun 1998 14:47:36 +0000 Subject: [PATCH] Fixed up images even more, added calls to get the appropriate bits_per_pixel --- gfx/src/motif/nsImageUnix.cpp | 36 ++++++++++++++++-------- gfx/src/motif/nsRenderingContextUnix.cpp | 6 ---- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/gfx/src/motif/nsImageUnix.cpp b/gfx/src/motif/nsImageUnix.cpp index 5f74a763c8d6..a1a09acc4953 100644 --- a/gfx/src/motif/nsImageUnix.cpp +++ b/gfx/src/motif/nsImageUnix.cpp @@ -49,7 +49,7 @@ nsImageUnix :: ~nsImageUnix() } if(nsnull != mImageBits) { - //delete[] (PRUint8*)mImageBits; + delete[] (PRUint8*)mImageBits; mImageBits = nsnull; } } @@ -138,7 +138,7 @@ PRInt32 spanbytes; spanbytes++; spanbytes <<= 2; - +printf("scanbytes: %d\n", spanbytes); return(spanbytes); } @@ -167,7 +167,6 @@ PRBool nsImageUnix :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurf { nsDrawingSurfaceUnix *unixdrawing =(nsDrawingSurfaceUnix*) aSurface; - printf("Draw::XPutImage %d %d %d %d %d %d\n", aSX,aSY,aDX,aDY,aDWidth,aDHeight); if (nsnull == mImage) return PR_FALSE; @@ -186,12 +185,15 @@ PRBool nsImageUnix :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurf { nsDrawingSurfaceUnix *unixdrawing =(nsDrawingSurfaceUnix*) aSurface; -printf("Draw::XPutImage2 %d %d %d %d %d %d\n", aX,aY,aX,aY,aWidth,aHeight); if (nsnull == mImage) return PR_FALSE; printf("Draw::XPutImage2 %d %d %d %d %d %d\n", aX,aY,aX,aY,aWidth,aHeight); XPutImage(unixdrawing->display,unixdrawing->drawable,unixdrawing->gc,mImage, - aX,aY,aX,aY,aWidth,aHeight); + 0,0,aX,aY,aWidth,aHeight); + +printf("DrawImage 0x%x 0x%x 0x%x \n", unixdrawing->display, + unixdrawing->drawable, + unixdrawing->gc); return PR_TRUE; } @@ -232,20 +234,32 @@ void nsImageUnix::CreateImage(nsDrawingSurface aSurface) if(mImageBits) { /* Need to support monochrome too */ - if (unixdrawing->visual->c_class == TrueColor || unixdrawing->visual->c_class == DirectColor) + if (unixdrawing->visual->c_class == TrueColor || + unixdrawing->visual->c_class == DirectColor) { format = ZPixmap; - else + printf("%s\n", (unixdrawing->visual->c_class == TrueColor?"True Color":"DirectColor")); + } else { format = XYPixmap; - + printf("Not True Color\n"); + } +printf("Width %d Height %d Visual Depth %d Image Depth %d\n", mWidth, mHeight, + unixdrawing->depth, mDepth); + mImage = ::XCreateImage(unixdrawing->display, unixdrawing->visual, unixdrawing->depth, format, 0, (char *)mImageBits, - mWidth, - mHeight, - 8,0); + (unsigned int)mWidth, + (unsigned int)mHeight, + 32,mRowBytes); + + mImage->byte_order = ImageByteOrder(unixdrawing->display); + mImage->bits_per_pixel = unixdrawing->depth; + mImage->bitmap_bit_order = BitmapBitOrder(unixdrawing->display); + mImage->bitmap_unit = 32; + } return ; } diff --git a/gfx/src/motif/nsRenderingContextUnix.cpp b/gfx/src/motif/nsRenderingContextUnix.cpp index 784a159e134d..50ca8eef9d97 100644 --- a/gfx/src/motif/nsRenderingContextUnix.cpp +++ b/gfx/src/motif/nsRenderingContextUnix.cpp @@ -561,7 +561,6 @@ void nsRenderingContextUnix :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, h = aHeight; mTMatrix->TransformCoord(&x,&y,&w,&h); - ::XFillRectangle(mRenderingSurface->display, mRenderingSurface->drawable, mRenderingSurface->gc, @@ -807,7 +806,6 @@ void nsRenderingContextUnix :: DrawString(const nsString& aString, void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY) { nscoord width,height; -printf("1-----------------------\n"); width = NS_TO_INT_ROUND(mP2T * aImage->GetWidth()); height = NS_TO_INT_ROUND(mP2T * aImage->GetHeight()); @@ -819,7 +817,6 @@ void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord a { nsRect tr; -printf("2-----------------------\n"); tr.x = aX; tr.y = aY; tr.width = aWidth; @@ -831,7 +828,6 @@ void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, const nsRect& aSRect, { nsRect sr,dr; - printf("nsRenderingContextUnixStretch :: DrawImage 0x%x\n",aImage); sr = aSRect; mTMatrix ->TransformCoord(&sr.x,&sr.y,&sr.width,&sr.height); @@ -846,7 +842,6 @@ void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, const nsRect& aRect) { nsRect tr; - printf("nsRenderingContextUnix :: DrawImage 0x%x\n",aImage); tr = aRect; mTMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height); @@ -860,7 +855,6 @@ nsRect tr; nsresult nsRenderingContextUnix :: CopyOffScreenBits(nsRect &aBounds) { -printf("CopyOffScreenBits-----------------------\n"); ::XCopyArea(mRenderingSurface->display, mRenderingSurface->drawable, mFrontBuffer->drawable,