added code for image, fixed a bug

This commit is contained in:
dcone 1998-06-17 22:55:42 +00:00
parent 71a4c698da
commit a4c0e4c9e9
2 changed files with 13 additions and 16 deletions

View File

@ -32,6 +32,9 @@ nsImageUnix :: nsImageUnix()
NS_INIT_REFCNT();
mImage = nsnull ;
mWidth = 0;
mHeight = 0;
mDepth = 0;
}
//------------------------------------------------------------
@ -92,9 +95,6 @@ PRInt32 spanbytes;
// set up the pallete to the passed in color array, RGB only in this array
void nsImageUnix :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect)
{
if (nsnull == mImage) {
CreateImage(aContext);
}
if (nsnull == mImage)
return;
@ -150,27 +150,24 @@ PRBool nsImageUnix::SetAlphaMask(nsIImage *aTheMask)
nsresult nsImageUnix::Optimize(nsDrawingSurface aDrawingSurface)
{
return(NS_OK);
if (nsnull == mImage) {
CreateImage(aDrawingSurface);
}
}
//------------------------------------------------------------
void nsImageUnix::CreateImage(nsIDeviceContext * aDeviceContext)
void nsImageUnix::CreateImage(nsDrawingSurface aSurface)
{
/* The XImage must be compatible with the Pixmap we draw into */
nsDrawingSurfaceUnix * surface = (nsDrawingSurfaceUnix *)
((nsDeviceContextUnix *)aDeviceContext)->GetDrawingSurface();
XWindowAttributes wa;
PRUint32 wdepth;
Visual * visual ;
PRUint32 format ;
nsDrawingSurfaceUnix *unixdrawing =(nsDrawingSurfaceUnix*) aSurface;
char * data = (char *) PR_Malloc(sizeof(char) * mWidth * mHeight * mDepth);
::XGetWindowAttributes(surface->display,
surface->drawable,
::XGetWindowAttributes(unixdrawing->display,
unixdrawing->drawable,
&wa);
/* XXX What if mDepth != wDepth */
@ -183,7 +180,7 @@ void nsImageUnix::CreateImage(nsIDeviceContext * aDeviceContext)
else
format = XYPixmap;
mImage = ::XCreateImage(surface->display,
mImage = ::XCreateImage(unixdrawing->display,
visual,
wdepth,
format,

View File

@ -46,7 +46,7 @@ public:
virtual nsColorMap* GetColorMap() {return nsnull;}
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
virtual PRBool IsOptimized() { return PR_FALSE; }
virtual PRBool IsOptimized() { return (mImage!=nsnull); }
virtual nsresult Optimize(nsDrawingSurface aSurface);
virtual PRUint8* GetAlphaBits() { return nsnull; }
virtual PRInt32 GetAlphaWidth() { return 0;}
@ -81,7 +81,7 @@ public:
virtual void MoveAlphaMask(PRInt32 aX, PRInt32 aY) {}
private:
void CreateImage(nsIDeviceContext * aDeviceContext);
void CreateImage(nsDrawingSurface aSurface);
/**
* Calculate the amount of memory needed for the initialization of the image