Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsImagePh Class Reference

#include <nsImagePh.h>

Inheritance diagram for nsImagePh:
Inheritance graph
[legend]
Collaboration diagram for nsImagePh:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsImagePh ()
virtual ~nsImagePh ()
virtual NS_DECL_ISUPPORTS PRInt32 GetBytesPix ()
virtual PRInt32 GetHeight ()
 Get the height for the pixelmap - dwc 2/1/99.
virtual PRInt32 GetWidth ()
 Get the width for the pixelmap - dwc 2/1/99.
virtual PRUint8GetBits ()
 Get a pointer to the bits for the pixelmap, only if it is not optimized - dwc 2/1/99.
virtual voidGetBitInfo ()
 Return information about the bits for this structure - dwc 2/1/99.
virtual PRBool GetIsRowOrderTopToBottom ()
 Get whether rows are organized top to bottom, or bottom to top - syd 3/29/99.
virtual PRInt32 GetLineStride ()
 Get the number of bytes needed to get to the next scanline for the pixelmap - dwc 2/1/99.
NS_IMETHODIMP SetDecodedRect (PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2)
virtual PRInt32 GetDecodedX1 ()
virtual PRInt32 GetDecodedY1 ()
virtual PRInt32 GetDecodedX2 ()
virtual PRInt32 GetDecodedY2 ()
NS_IMETHOD SetNaturalWidth (PRInt32 naturalwidth)
NS_IMETHOD SetNaturalHeight (PRInt32 naturalheight)
virtual PRInt32 GetNaturalWidth ()
virtual PRInt32 GetNaturalHeight ()
virtual nsColorMapGetColorMap ()
 Get the colormap for the nsIImage - dwc 2/1/99.
NS_IMETHOD Draw (nsIRenderingContext &aContext, nsIDrawingSurface *aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
 BitBlit the nsIImage to a device, the source can be scaled to the dest - dwc 2/1/99.
NS_IMETHOD Draw (nsIRenderingContext &aContext, nsIDrawingSurface *aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
 
Draw the bitmap, this method has a source and destination coordinates dc - 11/20/98
NS_IMETHOD DrawToImage (nsIImage *aDstImage, nscoord aDX, nscoord aDY, nscoord aDWidth, nscoord aDHeight)
 BitBlit the entire (no cropping) nsIImage to another nsImage, the source and dest can be scaled - saari 03/08/01.
NS_IMETHOD DrawTile (nsIRenderingContext &aContext, nsIDrawingSurface *aSurface, PRInt32 aSXOffset, PRInt32 aSYOffset, PRInt32 aPadX, PRInt32 aPadY, const nsRect &aTileRect)
virtual void ImageUpdated (nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect)
 Update the nsIImage color table - dwc 2/1/99.
virtual PRBool GetIsImageComplete ()
 
See documentation in nsIImage.h
virtual nsresult Init (PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements)
 
Initialize the nsImagePh object
virtual nsresult Optimize (nsIDeviceContext *aContext)
 Converted this pixelmap to an optimized pixelmap for the device - dwc 2/1/99.
virtual PRBool GetHasAlphaMask ()
 Get whether this image has an alpha mask.
virtual PRUint8GetAlphaBits ()
 Get a pointer to the bits for the alpha mask - dwc 2/1/99.
virtual PRInt32 GetAlphaWidth ()
virtual PRInt32 GetAlphaHeight ()
virtual PRInt32 GetAlphaLineStride ()
 Get the number of bytes per scanline for the alpha mask - dwc 2/1/99.
virtual nsIImageDuplicateImage ()
virtual PRInt8 GetAlphaDepth ()
 Get the alpha depth for the image mask - lordpixel 2001/05/16.
virtual void MoveAlphaMask (PRInt32 aX, PRInt32 aY)
NS_IMETHODIMP LockImagePixels (PRBool aMaskPixels)
 LockImagePixels Lock the image pixels so that we can access them directly, with safely.
NS_IMETHODIMP UnlockImagePixels (PRBool aMaskPixels)
 UnlockImagePixels Unlock the image pixels.

Private Member Functions

void ComputePaletteSize (PRIntn nBitCount)

Private Attributes

PRInt32 mWidth
PRInt32 mHeight
PRInt32 mDepth
PRInt32 mRowBytes
PRUint8mImageBits
PRInt8 mNumBytesPixel
PRUint8 mImageFlags
PRUint8 mDirtyFlags
PRInt32 mDecodedX1
PRInt32 mDecodedY1
PRInt32 mDecodedX2
PRInt32 mDecodedY2
PRUint8mAlphaBits
PRInt8 mAlphaDepth
PRInt16 mAlphaRowBytes
PRInt16 mAlphaWidth
PRInt16 mAlphaHeight
PhImage_t mPhImage
PhImage_t * mPhImageZoom
PRInt32 mDecodedY2_when_scaled
PRInt32 mNaturalWidth
PRInt32 mNaturalHeight

Detailed Description

Definition at line 45 of file nsImagePh.h.


Constructor & Destructor Documentation

Definition at line 59 of file nsImagePh.cpp.

Here is the call graph for this function:

nsImagePh::~nsImagePh ( ) [virtual]

Definition at line 81 of file nsImagePh.cpp.

{
  if (mImageBits != nsnull)
  {
       if( mImageFlags & IMAGE_SHMEM ) PgShmemDestroy( mImageBits );
              else delete [] mImageBits;
    mImageBits = nsnull;
  }

  if (mAlphaBits != nsnull)
  {
              if( mImageFlags & ALPHA_SHMEM ) PgShmemDestroy( mAlphaBits );
    else delete [] mAlphaBits;
    mAlphaBits = nsnull;
  }

       if( mPhImageZoom ) {
              if( mImageFlags & ZOOM_SHMEM ) PgShmemDestroy( mPhImageZoom->image );
              else free( mPhImageZoom->image );
              if( mPhImageZoom->mask_bm )
                     free( mPhImageZoom->mask_bm );
              free( mPhImageZoom );
              mPhImageZoom = NULL;
              }

  memset(&mPhImage, 0, sizeof(PhImage_t));
}

Here is the call graph for this function:


Member Function Documentation

void nsImagePh::ComputePaletteSize ( PRIntn  nBitCount) [private]
NS_IMETHODIMP nsImagePh::Draw ( nsIRenderingContext aContext,
nsIDrawingSurface aSurface,
PRInt32  aX,
PRInt32  aY,
PRInt32  aWidth,
PRInt32  aHeight 
) [virtual]

BitBlit the nsIImage to a device, the source can be scaled to the dest - dwc 2/1/99.

Parameters:
aSurfacethe surface to blit to
aXThe destination horizontal location
aYThe destination vertical location
aWidthThe destination width of the pixelmap
aHeightThe destination height of the pixelmap
Returns:
if TRUE, no errors

Implements nsIImage.

Definition at line 414 of file nsImagePh.cpp.

{
       PhPoint_t pos = { aX, aY };

       if (!aSurface || !mImageBits)
              return (NS_ERROR_FAILURE);

       PhDrawContext_t *dc = ((nsDrawingSurfacePh*)aSurface)->GetDC();

       if ((mAlphaDepth == 1) || (mAlphaDepth == 0))
       {
              if( mImageFlags & IMAGE_SHMEM )
                     PgDrawPhImageCxv( dc, &pos, &mPhImage, 0 );
              else PgDrawPhImageCx( dc, &pos, &mPhImage, 0 );
       }
       else if (mAlphaDepth == 8)
       {
              PgMap_t map;
              PhGC_t *gc = PgGetGCCx( dc );

              map.dim.w = mAlphaWidth;
              map.dim.h = mAlphaHeight;
              map.bpl = mAlphaRowBytes;
              map.bpp = mAlphaDepth;
              map.map = (unsigned char *)mAlphaBits;
              PgSetAlphaBlendCx( gc, &map, 0 );

              PgAlphaOnCx( gc );
              if( mImageFlags & IMAGE_SHMEM )
                     PgDrawPhImageCxv( dc, &pos, &mPhImage, 0 );
              else PgDrawPhImageCx( dc, &pos, &mPhImage, 0 );
              PgAlphaOffCx( gc );

              PgSetAlphaBlendCx( gc, NULL, 0 ); /* this shouldn't be necessary, but the ph lib's gc is holding onto our mAlphaBits */
       }

       return NS_OK;
}
NS_IMETHODIMP nsImagePh::Draw ( nsIRenderingContext aContext,
nsIDrawingSurface aSurface,
PRInt32  aSX,
PRInt32  aSY,
PRInt32  aSWidth,
PRInt32  aSHeight,
PRInt32  aDX,
PRInt32  aDY,
PRInt32  aDWidth,
PRInt32  aDHeight 
) [virtual]


Draw the bitmap, this method has a source and destination coordinates dc - 11/20/98

Parameters:
aContext- the rendering context to draw with
aSurface- The HDC in a nsDrawingsurfacePh to copy the bits to.
aSX- source horizontal location
aSY- source vertical location
aSWidth- source width
aSHeight- source height
aDX- destination location
aDY- destination location
aDWidth- destination width
aDHeight- destination height
Returns:
NS_OK if the draw worked
  • ATENTIE */ printf( "this=%p size=%d,%d src=(%d %d %d %d) dest=(%d %d %d %d)\n",
  • ATENTIE */ printf( "\t\t\tzoom from=%d,%d to=%d,%d\n", mPhImage.size.w, mPhImage.size.h, scaled_w, scaled_h );

Implements nsIImage.

Definition at line 271 of file nsImagePh.cpp.

{
       PhRect_t clip = { {aDX, aDY}, {aDX + aDWidth-1, aDY + aDHeight-1} };
       PhPoint_t pos = { aDX - aSX, aDY - aSY};
       int use_zoom = 0;

       if( !aSWidth || !aSHeight || !aDWidth || !aDHeight ) return NS_OK;

//this, mPhImage.size.w, mPhImage.size.h, aSX, aSY, aSWidth, aSHeight, aDX, aDY, aDWidth, aDHeight );

              PhDrawContext_t *dc = ((nsDrawingSurfacePh*)aSurface)->GetDC();
              PhGC_t *gc = PgGetGCCx( dc );
              if( (aSWidth != aDWidth || aSHeight != aDHeight) ) {

                     /* the case below happens frequently - a 1x1 image needs to be stretched, or a line or a column */
                     if( aSWidth == 1 && aSHeight == 1 || aSWidth == 1 && aSHeight == aDHeight || aDHeight == 1 && aSWidth == aDWidth ) {
                            /* you can strech the image by drawing it repeateadly */

                            PhPoint_t space = { 0, 0 };
                            PhPoint_t rep = { aDWidth, aDHeight };

                            /* is this a 1x1 transparent image used for spacing? */
                            if( mWidth == 1 && mHeight == 1 && mAlphaDepth == 1 && mAlphaBits[0] == 0x0 ) return NS_OK;

              PgSetMultiClipCx( gc, 1, &clip );
              if ((mAlphaDepth == 1) || (mAlphaDepth == 0)) {
                                   if( mImageFlags & IMAGE_SHMEM )
                     PgDrawRepPhImageCxv( dc, &mPhImage, 0, &pos, &rep, &space );
                                   else PgDrawRepPhImageCx( dc, &mPhImage, 0, &pos, &rep, &space );
                                   }
              else
              {
                PgMap_t map;
                map.dim.w = mAlphaWidth;
                map.dim.h = mAlphaHeight;
                map.bpl = mAlphaRowBytes;
                map.bpp = mAlphaDepth;
                map.map = (unsigned char *)mAlphaBits;
                PgSetAlphaBlendCx( gc, &map, 0 );

                PgAlphaOnCx( gc );
                                   if( mImageFlags & IMAGE_SHMEM )
                     PgDrawRepPhImageCxv( dc, &mPhImage, 0, &pos, &rep, &space );
                else PgDrawRepPhImageCx( dc, &mPhImage, 0, &pos, &rep, &space );
                PgAlphaOffCx( gc );

                                   PgSetAlphaBlendCx( gc, NULL, 0 ); /* this shouldn't be necessary, but the ph lib's gc is holding onto our mAlphaBits */
              }
              PgSetMultiClipCx( gc, 0, NULL );

                            return NS_OK;
                            }

                     else if( mPhImage.size.h > 0 ) {

                            /* keeping the proportions, what is the size of mPhImageZoom that can give use the aDWidth and aDHeight? */
                            PRInt32 scaled_w = aDWidth * mPhImage.size.w / aSWidth;
                            PRInt32 scaled_h = aDHeight * mPhImage.size.h / aSHeight;
                            use_zoom = 1;
                            
                            if( mPhImageZoom == NULL || mPhImageZoom->size.w != scaled_w || mPhImageZoom->size.h != scaled_h || mDecodedY2_when_scaled != mDecodedY2 || mDirtyFlags != 0 ) {

                                   /* we already had a scaled image, but the scaling factor was different from what we need now */
                                   mDirtyFlags = 0;

              if ( mPhImageZoom ) {
                                          if( mImageFlags & ZOOM_SHMEM ) {
                                                 PgFlushCx( dc );
                                                 PgWaitHWIdle();
                                                 PgShmemDestroy( mPhImageZoom->image );
                                                 }
                                          else free( mPhImageZoom->image );
                                          if( mPhImageZoom->mask_bm )
                                       free( mPhImageZoom->mask_bm );
                                          free( mPhImageZoom );
                                          mPhImageZoom = NULL;
                }

                                   /* record the mDecodedY1 at the time of scaling */
                                   mDecodedY2_when_scaled = mDecodedY2;

                                   /* this is trying to estimate the image data size of the zoom image */
                                   if (( mPhImage.bpl * scaled_w * scaled_h / mPhImage.size.w ) < IMAGE_SHMEM_THRESHOLD) {
                                          mPhImageZoom = PiResizeImage( &mPhImage, NULL, scaled_w, scaled_h, Pi_USE_COLORS);
                                          mImageFlags &= ~ZOOM_SHMEM;
                                          }
                                   else {
                                          mPhImageZoom = PiResizeImage( &mPhImage, NULL, scaled_w, scaled_h, Pi_USE_COLORS|Pi_SHMEM);
                                          mImageFlags |= ZOOM_SHMEM;
                                          }

                                   }
                            }
                     }

              PgSetMultiClipCx( gc, 1, &clip );
              if ((mAlphaDepth == 1) || (mAlphaDepth == 0)) {
                     if( use_zoom ) {
                            if( mImageFlags & ZOOM_SHMEM )
                                   PgDrawPhImageCxv( dc, &pos, mPhImageZoom, 0 );
                            else PgDrawPhImageCx( dc, &pos, mPhImageZoom, 0 );
                            }
                     else {
                            if( mImageFlags & IMAGE_SHMEM )
                                   PgDrawPhImageCxv( dc, &pos, &mPhImage, 0 );
                            else PgDrawPhImageCx( dc, &pos, &mPhImage, 0 );
                            }
                     }
              else
              {
                     PgMap_t map;

                     map.dim.w = mAlphaWidth;
                     map.dim.h = mAlphaHeight;
                     map.bpl = mAlphaRowBytes;
                     map.bpp = mAlphaDepth;
                     map.map = (unsigned char *)mAlphaBits;
                     PgSetAlphaBlendCx( gc, &map, 0 );

                     PgAlphaOnCx( gc );
                     if( use_zoom ) {
                            if( mImageFlags & ZOOM_SHMEM )
                                   PgDrawPhImageCxv( dc, &pos, mPhImageZoom, 0 );
                            else PgDrawPhImageCx( dc, &pos, mPhImageZoom, 0 );
                            }
                     else {
                            if( mImageFlags & IMAGE_SHMEM )
                                   PgDrawPhImageCxv( dc, &pos, &mPhImage, 0 );
                            else PgDrawPhImageCx( dc, &pos, &mPhImage, 0 );
                            }
                     PgAlphaOffCx( gc );

                     PgSetAlphaBlendCx( gc, NULL, 0 ); /* this shouldn't be necessary, but the ph lib's gc is holding onto our mAlphaBits */
              }
              PgSetMultiClipCx( gc, 0, NULL );

       return NS_OK;
}
NS_IMETHODIMP nsImagePh::DrawTile ( nsIRenderingContext aContext,
nsIDrawingSurface aSurface,
PRInt32  aSXOffset,
PRInt32  aSYOffset,
PRInt32  aPadX,
PRInt32  aPadY,
const nsRect aTileRect 
) [virtual]

Implements nsIImage.

Definition at line 455 of file nsImagePh.cpp.

{
       PhPoint_t pos, space, rep;
       PhDrawContext_t *dc ;
       PhGC_t *gc;

       /* is this a 1x1 transparent image used for spacing? */
       if( mWidth == 1 && mHeight == 1 && mAlphaDepth == 1 && mAlphaBits[0] == 0x0 ) return NS_OK;

       dc = ((nsDrawingSurfacePh*)aSurface)->GetDC();
       gc = PgGetGCCx( dc );

       // since there is an offset into the image and I only want to draw full
       // images, shift the position back and set clipping so that it looks right
       pos.x = aTileRect.x - aSXOffset;
       pos.y = aTileRect.y - aSYOffset;

       space.x = mPhImage.size.w + aPadX;
       space.y = mPhImage.size.h + aPadY;
       rep.x = ( aTileRect.width + aSXOffset + space.x - 1 ) / space.x;
       rep.y = ( aTileRect.height + aSYOffset + space.y - 1 ) / space.y;

       /* not sure if cliping is necessary */
       PhRect_t clip = { {aTileRect.x, aTileRect.y}, {aTileRect.x + aTileRect.width-1, aTileRect.y + aTileRect.height-1} };
       PgSetMultiClipCx( gc, 1, &clip );

       if ((mAlphaDepth == 1) || (mAlphaDepth == 0)) {
              if( mImageFlags & IMAGE_SHMEM )
              PgDrawRepPhImageCxv( dc, &mPhImage, 0, &pos, &rep, &space );
         else PgDrawRepPhImageCx( dc, &mPhImage, 0, &pos, &rep, &space );
              }
       else
              {
    PgMap_t map;
    map.dim.w = mAlphaWidth;
    map.dim.h = mAlphaHeight;
    map.bpl = mAlphaRowBytes;
    map.bpp = mAlphaDepth;
    map.map = (unsigned char *)mAlphaBits;
    PgSetAlphaBlendCx( gc, &map, 0 );
       
    PgAlphaOnCx( gc );
              if( mImageFlags & IMAGE_SHMEM )
       PgDrawRepPhImageCxv( dc, &mPhImage, 0, &pos, &rep, &space );
    else PgDrawRepPhImageCx( dc, &mPhImage, 0, &pos, &rep, &space );
    PgAlphaOffCx( gc );

              PgSetAlphaBlendCx( gc, NULL, 0 ); /* this shouldn't be necessary, but the ph lib's gc is holding onto our mAlphaBits */
              }

       PgSetMultiClipCx( gc, 0, NULL );

       return NS_OK;
}
NS_IMETHODIMP nsImagePh::DrawToImage ( nsIImage aDstImage,
nscoord  aDX,
nscoord  aDY,
nscoord  aDWidth,
nscoord  aDHeight 
) [virtual]

BitBlit the entire (no cropping) nsIImage to another nsImage, the source and dest can be scaled - saari 03/08/01.

Parameters:
aDstImagethe nsImage to blit to
aDXThe destination horizontal location
aDYThe destination vertical location
aDWidthThe destination width of the pixelmap
aDHeightThe destination height of the pixelmap
Returns:
if TRUE, no errors

Implements nsIImage.

Definition at line 536 of file nsImagePh.cpp.

{
  nsImagePh *dest = NS_STATIC_CAST(nsImagePh *, aDstImage);

  if (!dest)
    return NS_ERROR_FAILURE;

  if (!dest->mPhImage.image)
    return NS_ERROR_FAILURE;

       PhArea_t sarea, darea;
       PhImage_t *pimage = NULL;
       int start, x, y;
       char mbit, mbyte;
       int release = 0;
              
       sarea.pos.x = sarea.pos.y = 0;
       darea.pos.x = aDX;
       darea.pos.y = aDY;
       darea.size.w = sarea.size.w = aDWidth;
       darea.size.h = sarea.size.h = aDHeight;

       if( mPhImage.size.h > 0 && ( aDWidth != mPhImage.size.w || aDHeight != mPhImage.size.h ) )
       {
              release = 1;
              if ((aDHeight * mPhImage.bpl) < IMAGE_SHMEM_THRESHOLD)
                     pimage = PiResizeImage(&mPhImage, NULL, aDWidth, aDHeight, Pi_USE_COLORS);
              else
                     pimage = PiResizeImage(&mPhImage, NULL, aDWidth, aDHeight, Pi_USE_COLORS|Pi_SHMEM);
       }
       else pimage = &mPhImage;

       if( pimage == NULL ) return NS_OK;

       start = (aDY * dest->mPhImage.bpl) + (aDX * mNumBytesPixel);
       for (y = 0; y < pimage->size.h; y++)
       {
              for (x = 0; x < pimage->size.w; x++)
              {
                     if (pimage->mask_bm)
                     {
                            mbyte = *(pimage->mask_bm + (pimage->mask_bpl * y) + (x >> 3));
                            mbit = x & 7;
                            if (!(mbyte & (0x80 >> mbit)))
                                   continue;
                     }
                     memcpy(dest->mPhImage.image + start + (dest->mPhImage.bpl * y) + (x*mNumBytesPixel), 
                               pimage->image + (pimage->bpl * y) + (x*mNumBytesPixel), mNumBytesPixel);
              }
       }

       if( release ) {
              pimage->flags = Ph_RELEASE_IMAGE_ALL;
              PhReleaseImage(pimage);
              free( pimage );
              }

       return NS_OK;
}

Here is the call graph for this function:

virtual nsIImage* nsImagePh::DuplicateImage ( ) [inline, virtual]

Definition at line 121 of file nsImagePh.h.

{ return nsnull; }
virtual PRUint8* nsImagePh::GetAlphaBits ( ) [inline, virtual]

Get a pointer to the bits for the alpha mask - dwc 2/1/99.

Returns:
address of the alpha mask pixel array

Implements nsIImage.

Definition at line 117 of file nsImagePh.h.

{ return mAlphaBits; }
virtual PRInt8 nsImagePh::GetAlphaDepth ( ) [inline, virtual]

Get the alpha depth for the image mask - lordpixel 2001/05/16.

Returns:
the alpha mask depth for the image, ie, 0, 1 or 8

Implements nsIImage.

Definition at line 128 of file nsImagePh.h.

{ return mAlphaDepth; }  
virtual PRInt32 nsImagePh::GetAlphaHeight ( ) [inline, virtual]

Definition at line 119 of file nsImagePh.h.

{ return mAlphaHeight; }
virtual PRInt32 nsImagePh::GetAlphaLineStride ( ) [inline, virtual]

Get the number of bytes per scanline for the alpha mask - dwc 2/1/99.

Returns:
The number of bytes in each scanline

Implements nsIImage.

Definition at line 120 of file nsImagePh.h.

{ return mAlphaRowBytes; }
virtual PRInt32 nsImagePh::GetAlphaWidth ( ) [inline, virtual]

Definition at line 118 of file nsImagePh.h.

{ return mAlphaWidth; }
virtual void* nsImagePh::GetBitInfo ( ) [inline, virtual]

Return information about the bits for this structure - dwc 2/1/99.

Returns:
a bitmap info structure for the Device Dependent Bits

Implements nsIImage.

Definition at line 61 of file nsImagePh.h.

{ return nsnull; }
virtual PRUint8* nsImagePh::GetBits ( ) [inline, virtual]

Get a pointer to the bits for the pixelmap, only if it is not optimized - dwc 2/1/99.

Returns:
address of the DIB pixel array

Implements nsIImage.

Definition at line 59 of file nsImagePh.h.

{  return mImageBits; }
virtual NS_DECL_ISUPPORTS PRInt32 nsImagePh::GetBytesPix ( ) [inline, virtual]
See also:
nsIImage.h

Implements nsIImage.

Definition at line 55 of file nsImagePh.h.

{ return mNumBytesPixel; }
virtual nsColorMap* nsImagePh::GetColorMap ( ) [inline, virtual]

Get the colormap for the nsIImage - dwc 2/1/99.

Returns:
if non null, the colormap for the pixelmap,otherwise the image is not color mapped

Implements nsIImage.

Definition at line 87 of file nsImagePh.h.

{ return nsnull; }
virtual PRInt32 nsImagePh::GetDecodedX1 ( ) [inline, virtual]

Definition at line 76 of file nsImagePh.h.

{ return mDecodedX1;}
virtual PRInt32 nsImagePh::GetDecodedX2 ( ) [inline, virtual]

Definition at line 78 of file nsImagePh.h.

{ return mDecodedX2;}
virtual PRInt32 nsImagePh::GetDecodedY1 ( ) [inline, virtual]

Definition at line 77 of file nsImagePh.h.

{ return mDecodedY1;}
virtual PRInt32 nsImagePh::GetDecodedY2 ( ) [inline, virtual]

Definition at line 79 of file nsImagePh.h.

{ return mDecodedY2;}
virtual PRBool nsImagePh::GetHasAlphaMask ( ) [inline, virtual]

Get whether this image has an alpha mask.

Preferable to testing if GetAlphaBits() is non-null. - sfraser 10/19/99

Returns:
PR_TRUE if the image has an alpha mask, PR_FALSE otherwise

Implements nsIImage.

Definition at line 116 of file nsImagePh.h.

{ return mAlphaBits != nsnull; } 
virtual PRInt32 nsImagePh::GetHeight ( ) [inline, virtual]

Get the height for the pixelmap - dwc 2/1/99.

Returns:
The height in pixels for the pixelmap

Implements nsIImage.

Definition at line 56 of file nsImagePh.h.

{ return mHeight; }


See documentation in nsIImage.h

Implements nsIImage.

Definition at line 249 of file nsImagePh.cpp.

                                     {
  return mDecodedX1 == 0 &&
         mDecodedY1 == 0 &&
         mDecodedX2 == mWidth &&
         mDecodedY2 == mHeight;
}
virtual PRBool nsImagePh::GetIsRowOrderTopToBottom ( ) [inline, virtual]

Get whether rows are organized top to bottom, or bottom to top - syd 3/29/99.

Returns:
PR_TRUE if top to bottom, else PR_FALSE

Implements nsIImage.

Definition at line 63 of file nsImagePh.h.

{ return PR_TRUE; }
virtual PRInt32 nsImagePh::GetLineStride ( ) [inline, virtual]

Get the number of bytes needed to get to the next scanline for the pixelmap - dwc 2/1/99.

Returns:
The number of bytes in each scanline

Implements nsIImage.

Definition at line 64 of file nsImagePh.h.

{ return mRowBytes; }
virtual PRInt32 nsImagePh::GetNaturalHeight ( ) [inline, virtual]

Definition at line 84 of file nsImagePh.h.

{return mNaturalHeight; }
virtual PRInt32 nsImagePh::GetNaturalWidth ( ) [inline, virtual]

Definition at line 83 of file nsImagePh.h.

{return mNaturalWidth; }
virtual PRInt32 nsImagePh::GetWidth ( ) [inline, virtual]

Get the width for the pixelmap - dwc 2/1/99.

Returns:
The width in pixels for the pixelmap

Implements nsIImage.

Definition at line 57 of file nsImagePh.h.

{ return mWidth; }
virtual void nsImagePh::ImageUpdated ( nsIDeviceContext aContext,
PRUint8  aFlags,
nsRect aUpdateRect 
) [inline, virtual]

Update the nsIImage color table - dwc 2/1/99.

Parameters:
aFlagsUsed to pass in parameters for the update
aUpdateRectThe rectangle to update

Implements nsIImage.

Definition at line 100 of file nsImagePh.h.

              {
              PRInt32 y = aUpdateRect->YMost();
              PRInt32 x = aUpdateRect->XMost();
              if( y > mDecodedY2 ) mDecodedY2 = y;
              if( x > mDecodedX2 ) mDecodedX2 = x;
              mDirtyFlags = aFlags;
              mPhImage.size.h = mDecodedY2;
              }
nsresult nsImagePh::Init ( PRInt32  aWidth,
PRInt32  aHeight,
PRInt32  aDepth,
nsMaskRequirements  aMaskRequirements 
) [virtual]


Initialize the nsImagePh object

Parameters:
aWidth- Width of the image
aHeight- Height of the image
aDepth- Depth of the image
aMaskRequirements- A mask used to specify if alpha is needed.
Returns:
NS_OK if the image was initied ok

Implements nsIImage.

Definition at line 117 of file nsImagePh.cpp.

{
       int type = -1;

       mImageFlags = 0;

       if (mImageBits != nsnull)
       {
              if( mImageFlags & IMAGE_SHMEM ) PgShmemDestroy( mImageBits );
              else delete [] mImageBits;
              mImageBits = nsnull;
       }

       if (mAlphaBits != nsnull)
       {
              if( mImageFlags & ALPHA_SHMEM ) PgShmemDestroy( mAlphaBits );
              else delete [] mAlphaBits;
              mAlphaBits = nsnull;
       }

       if( mPhImageZoom ) {
              if( mImageFlags & ZOOM_SHMEM ) PgShmemDestroy( mPhImageZoom->image );
              else free( mPhImageZoom->image );
              if( mPhImageZoom->mask_bm )
                     free( mPhImageZoom->mask_bm );
              free( mPhImageZoom );
              mPhImageZoom = NULL;
              }
  
  SetDecodedRect(0,0,0,0);  //init
 
  switch (aDepth)
    {
        case 24:
            type = Pg_IMAGE_DIRECT_888;
            mNumBytesPixel = 3;
            break;
//      case 16:
//          type = Pg_IMAGE_DIRECT_555;
//          mNumBytesPixel = 2;
//          break;
      case 8:
//          type = Pg_IMAGE_PALETTE_BYTE;
//          mNumBytesPixel = 1;
//          break;
        default:
            NS_ASSERTION(PR_FALSE, "unexpected image depth");
            return NS_ERROR_UNEXPECTED;
            break;
    }
 
       mWidth = aWidth;
       mHeight = aHeight;
       mDepth = aDepth;

       /* Allocate the Image Data */
       PRInt32 image_size = mNumBytesPixel * mWidth * mHeight;

       /* TODO: don't allow shared memory contexts if the graphics driver isn't a local device */

  if (image_size >= IMAGE_SHMEM_THRESHOLD)
  {
              mImageBits = (PRUint8 *) PgShmemCreate( image_size, NULL );
              mImageFlags |= IMAGE_SHMEM;
  }
  else
  {
              mImageBits = new PRUint8[ image_size ];
              memset( mImageBits, 0, image_size );
       }

       switch(aMaskRequirements)
       {
              default:
              case nsMaskRequirements_kNoMask:
                     mAlphaBits = nsnull;
                     mAlphaWidth = 0;
                     mAlphaHeight = 0;
                     mAlphaRowBytes = 0;
                     break;

              case nsMaskRequirements_kNeeds1Bit:
                     {
                     mAlphaRowBytes = (aWidth + 7) / 8;
                     mAlphaDepth = 1;

                     int alphasize = mAlphaRowBytes * aHeight;
                     mAlphaBits = new PRUint8[ alphasize ];
                     memset( mAlphaBits, 0, alphasize );

                     mAlphaWidth = aWidth;
                     mAlphaHeight = aHeight;
                     }
                     break;

              case nsMaskRequirements_kNeeds8Bit:
                     {
                     mAlphaRowBytes = aWidth;
                     mAlphaDepth = 8;

                     int alphasize = mAlphaRowBytes * aHeight;
                     if( alphasize > IMAGE_SHMEM_THRESHOLD ) {
                            mAlphaBits = ( PRUint8 * ) PgShmemCreate( alphasize, NULL );
                            mImageFlags |= ALPHA_SHMEM;
                            }
                     else mAlphaBits = new PRUint8[ alphasize ];
                     memset( mAlphaBits, 0, alphasize );

                     mAlphaWidth = aWidth;
                     mAlphaHeight = aHeight;
                     }
                     break;
       }

       // mPhImage.image_tag = PtCRC( (char *)mImageBits, image_size );
       mPhImage.image = (char *)mImageBits;
       mPhImage.size.w = mWidth;
       mPhImage.size.h = 0;
       mRowBytes = mPhImage.bpl = mNumBytesPixel * mWidth;
       mPhImage.type = type;
       if (aMaskRequirements == nsMaskRequirements_kNeeds1Bit)
       {
              mPhImage.mask_bm = (char *)mAlphaBits;
              mPhImage.mask_bpl = mAlphaRowBytes;
       }

       return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsImagePh::LockImagePixels ( PRBool  aMaskPixels) [inline, virtual]

LockImagePixels Lock the image pixels so that we can access them directly, with safely.

May be a noop on some platforms.

aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image

Must be balanced by a call to UnlockImagePixels().

- sfraser 10/18/99

Returns:
error result

Implements nsIImage.

Definition at line 132 of file nsImagePh.h.

{ return NS_OK; }
virtual void nsImagePh::MoveAlphaMask ( PRInt32  aX,
PRInt32  aY 
) [inline, virtual]

Definition at line 129 of file nsImagePh.h.

{ }
nsresult nsImagePh::Optimize ( nsIDeviceContext aContext) [virtual]

Converted this pixelmap to an optimized pixelmap for the device - dwc 2/1/99.

Parameters:
aContextThe device to optimize for
Returns:
the result of the operation, if NS_OK, then the pixelmap is optimized

Implements nsIImage.

Definition at line 514 of file nsImagePh.cpp.

{
       /* TODO: need to invalidate the caches if the graphics system has changed somehow (ie: mode switch, dragged to a remote
                     display, etc... */

       /* TODO: remote graphics drivers should always cache the images offscreen regardless of wether there is a mask or not,
                     the Draw code will need to be updated for this */

       return NS_OK;
}
NS_IMETHODIMP nsImagePh::SetDecodedRect ( PRInt32  x1,
PRInt32  y1,
PRInt32  x2,
PRInt32  y2 
) [inline]

Definition at line 67 of file nsImagePh.h.

              {
              mDecodedX1 = x1;
              mDecodedY1 = y1;
              mDecodedX2 = x2;
              mDecodedY2 = y2;
              return NS_OK;
              }

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsImagePh::SetNaturalHeight ( PRInt32  naturalheight) [inline]

Definition at line 82 of file nsImagePh.h.

{ mNaturalHeight= naturalheight; return NS_OK;}
NS_IMETHOD nsImagePh::SetNaturalWidth ( PRInt32  naturalwidth) [inline]

Definition at line 81 of file nsImagePh.h.

{ mNaturalWidth= naturalwidth; return NS_OK;}
NS_IMETHODIMP nsImagePh::UnlockImagePixels ( PRBool  aMaskPixels) [inline, virtual]

UnlockImagePixels Unlock the image pixels.

May be a noop on some platforms.

Should balance an earlier call to LockImagePixels().

aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image

- sfraser 10/18/99

Returns:
error result

Implements nsIImage.

Definition at line 135 of file nsImagePh.h.

{ return NS_OK; }

Member Data Documentation

Definition at line 157 of file nsImagePh.h.

PRInt8 nsImagePh::mAlphaDepth [private]

Definition at line 158 of file nsImagePh.h.

Definition at line 161 of file nsImagePh.h.

Definition at line 159 of file nsImagePh.h.

Definition at line 160 of file nsImagePh.h.

Definition at line 151 of file nsImagePh.h.

Definition at line 153 of file nsImagePh.h.

Definition at line 152 of file nsImagePh.h.

Definition at line 154 of file nsImagePh.h.

Definition at line 164 of file nsImagePh.h.

Definition at line 143 of file nsImagePh.h.

Definition at line 149 of file nsImagePh.h.

Definition at line 142 of file nsImagePh.h.

Definition at line 145 of file nsImagePh.h.

Definition at line 148 of file nsImagePh.h.

Definition at line 167 of file nsImagePh.h.

Definition at line 166 of file nsImagePh.h.

PRInt8 nsImagePh::mNumBytesPixel [private]

Definition at line 147 of file nsImagePh.h.

PhImage_t nsImagePh::mPhImage [private]

Definition at line 162 of file nsImagePh.h.

PhImage_t* nsImagePh::mPhImageZoom [private]

Definition at line 163 of file nsImagePh.h.

Definition at line 144 of file nsImagePh.h.

Definition at line 141 of file nsImagePh.h.


The documentation for this class was generated from the following files: