Added documentation

git-svn-id: svn://10.0.0.236/trunk@256 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dcone
1998-04-14 19:56:15 +00:00
parent 7481ae875e
commit 2e165099a3
2 changed files with 123 additions and 18 deletions

View File

@@ -55,39 +55,101 @@ typedef enum {
class nsIImage : public nsISupports
{
public:
//initialize the image. aDepth is either 8 or 24. if the image has an alpha
//channel, aNeedAlpha will be true
// had nsqresult for return, need to fix fix
/**
* Build and initialize the pixelmap
* @param aWidth The width in pixels of the desired pixelmap
* @param aHeight The height in pixels of the desired pixelmap
* @param aDepth The number of bits per pixel for the pixelmap
* @param aMaskRequirements A flag indicating if a alpha mask should be allocated
*/
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements) = 0;
//dimensioning in PIXELS
/**
* Get the width for the pixelmap
@return The width in pixels for the pixelmap
*/
virtual PRInt32 GetWidth() = 0;
/**
* Get the height for the pixelmap
@return The height in pixels for the pixelmap
*/
virtual PRInt32 GetHeight() = 0;
//if the image is not optimzed, get a pointer to the bits
/**
* Get a pointer to the bits for the pixelmap, only if it is not optimized
@return address of the DIB pixel array
*/
virtual PRUint8 * GetBits() = 0;
//get the number of bytes to jump from scanline to scanline
/**
* Get the number of bytes needed to get to the next scanline for the pixelmap
@return The number of bytes in each scanline
*/
virtual PRInt32 GetLineStride() = 0;
//if the image is not optimzed, get a pointer to the bits
/**
* Get a pointer to the bits for the alpha mask
@return address of the alpha mask pixel array
*/
virtual PRUint8 * GetAlphaBits() = 0;
//get the number of bytes to jump from scanline to scanline
/**
* Get the number of bytes needed to get to the next scanline for the alpha mask
@return The number of bytes in each scanline
*/
virtual PRInt32 GetAlphaLineStride() = 0;
/**
* Will update a pixelmaps color table
@param aFlags Used to pass in parameters for the update
@param aUpdateRect The rectangle to update
*/
virtual void ImageUpdated(PRUint8 aFlags, nsRect *aUpdateRect) = 0;
//has this image been optimized?
/**
* Returns if the pixelmap has been converted to an optimized pixelmap
@return If true, it is optimized
*/
virtual PRBool IsOptimized() = 0;
//convert this image to a version optimized for display
/**
* Converted this pixelmap to an optimized pixelmap for the device
@param aSurface The surface to optimize for
@return the result of the operation, if NS_OK, then the pixelmap is optimized
*/
virtual nsresult Optimize(nsDrawingSurface aSurface) = 0;
//if this returns non-null, this image is color mapped
/**
* Get the colormap for the pixelmap
@return if non null, the colormap for the pixelmap,otherwise the image is not color mapped
*/
virtual nsColorMap * GetColorMap() = 0;
/**
* BitBlit the pixelmap to a device, the source can be scale to the dest
@param aSurface the surface to blit to
@param aX The destination horizontal location
@param aY The destination vertical location
@param aWidth The destination width of the pixelmap
@param aHeight The destination height of the pixelmap
@return if TRUE, no errors
*/
virtual PRBool Draw(nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
/**
* BitBlit the pixelmap to a device, the source and dest can be scaled
@param aSurface the surface to blit to
@param aSX The source width of the pixelmap
@param aSY The source vertical location
@param aSWidth The source width of the pixelmap
@param aSHeight The source height of the pixelmap
@param aDX The destination horizontal location
@param aDY The destination vertical location
@param aDWidth The destination width of the pixelmap
@param aDHeight The destination height of the pixelmap
@return if TRUE, no errors
*/
virtual PRBool Draw(nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;

View File

@@ -29,14 +29,15 @@ public:
NS_DECL_ISUPPORTS
/**
@see nsIImage.h
*/
virtual PRInt32 GetHeight() { return mBHead->biHeight; }
virtual PRInt32 GetWidth() { return mBHead->biWidth; }
virtual PRUint8* GetAlphaBits() { return mAlphaBits; }
virtual PRInt32 GetAlphaLineStride(){ return mBHead->biWidth; }
virtual PRUint8* GetBits() { return mImageBits; }
PRIntn GetSizeHeader() {return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * mNumPalleteColors;}
virtual PRInt32 GetLineStride() {return mRowBytes; }
PRIntn GetSizeImage() { return mSizeImage; }
virtual PRBool Draw(nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool Draw(nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
@@ -44,16 +45,58 @@ public:
virtual void ImageUpdated(PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
virtual PRBool IsOptimized() { return mIsOptimized; }
PRBool MakePalette();
virtual nsresult Optimize(nsDrawingSurface aSurface);
PRBool SetSystemPalette(HDC* aHdc);
PRUintn UsePalette(HDC* aHdc, PRBool bBackground = PR_FALSE);
void TestFillBits();
PRInt32 TestSpeedBits(nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
/**
* Return the header size of the Device Independent Bitmap(DIB).
* @return size of header in bytes
*/
PRIntn GetSizeHeader(){return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * mNumPalleteColors;}
/**
* Return the image size of the Device Independent Bitmap(DIB).
* @return size of image in bytes
*/
PRIntn GetSizeImage(){ return mSizeImage; }
/**
* Make a palette for the DIB.
* @return true or false if the palette was created
*/
PRBool MakePalette();
/**
* Set the for this pixelmap to the system palette.
* @param aHdc is the DC to get the palette from to use
* @return true or false if the palette was set
*/
PRBool SetSystemPalette(HDC* aHdc);
/**
* Set the palette for an HDC.
* @param aHDC is the DC to set the palette to
* @param bBackround tells if the DC is in the background
* @return true or false if the palette was set
*/
PRUintn UsePalette(HDC* aHdc, PRBool bBackground = PR_FALSE);
private:
/**
* Clean up the memory used nsImageWin.
* @param aCleanUpAll if True, all the memory used will be released otherwise just clean up the DIB memory
*/
void CleanUp(PRBool aCleanUpAll);
/**
* Calculate the amount of memory needed for the palette
* @param aBitCount is the number of bits per pixel
*/
void ComputePaletteSize(PRIntn aBitCount);
/**
* Calculate the amount of memory needed for the initialization of the pixelmap
*/
void ComputeMetrics();
PRInt8 mNumBytesColor; // number of bytes per color