2001-09-26 00:16:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-26 00:16:04 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-26 00:16:04 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:43:54 +00:00
|
|
|
*
|
2001-09-26 00:16:04 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-26 00:16:04 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-26 00:16:04 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-26 00:16:04 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#ifndef nsIImage_h___
|
|
|
|
#define nsIImage_h___
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
2004-11-15 04:16:07 +00:00
|
|
|
#include "nsRect.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2006-03-25 00:34:48 +00:00
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
class gfxASurface;
|
|
|
|
#endif
|
|
|
|
|
2001-07-16 02:40:48 +00:00
|
|
|
class nsIDeviceContext;
|
|
|
|
|
|
|
|
struct nsColorMap
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
//I lifted this from the image lib. The difference is that
|
|
|
|
//this uses nscolor instead of NI_RGB. Multiple color pollution
|
|
|
|
//is a bad thing. MMP
|
|
|
|
PRInt32 NumColors; // Number of colors in the colormap.
|
|
|
|
// A negative value can be used to denote a
|
|
|
|
// possibly non-unique set.
|
|
|
|
//nscolor *Map; // Colormap colors.
|
|
|
|
PRUint8 *Index; // NULL, if map is in index order, otherwise
|
|
|
|
// specifies the indices of the map entries. */
|
2001-07-16 02:40:48 +00:00
|
|
|
};
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
nsMaskRequirements_kNoMask,
|
|
|
|
nsMaskRequirements_kNeeds1Bit,
|
|
|
|
nsMaskRequirements_kNeeds8Bit
|
|
|
|
} nsMaskRequirements;
|
|
|
|
|
|
|
|
|
|
|
|
#define nsImageUpdateFlags_kColorMapChanged 0x1
|
|
|
|
#define nsImageUpdateFlags_kBitsChanged 0x2
|
2005-02-20 03:21:04 +00:00
|
|
|
|
2006-03-10 22:27:37 +00:00
|
|
|
#ifndef MOZ_CAIRO_GFX
|
2005-02-20 03:21:04 +00:00
|
|
|
// The following platforms store image data rows bottom-up.
|
|
|
|
#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_MACOSX)
|
|
|
|
#define MOZ_PLATFORM_IMAGES_BOTTOM_TO_TOP
|
|
|
|
#endif
|
2006-03-10 22:27:37 +00:00
|
|
|
#endif
|
2005-02-20 03:21:04 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// IID for the nsIImage interface
|
|
|
|
#define NS_IIMAGE_IID \
|
2004-11-15 04:16:07 +00:00
|
|
|
{ 0xce91c93f, 0x532d, 0x470d, \
|
|
|
|
{ 0xbf, 0xa3, 0xc9, 0x6e, 0x56, 0x01, 0x52, 0xa4 } }
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// Interface to Images
|
|
|
|
class nsIImage : public nsISupports
|
|
|
|
{
|
1998-05-13 14:28:16 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
public:
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIMAGE_IID)
|
1998-05-13 14:28:16 +00:00
|
|
|
|
1998-04-14 19:56:15 +00:00
|
|
|
/**
|
1999-02-08 16:34:56 +00:00
|
|
|
* Build and initialize the nsIImage
|
1998-04-14 19:56:15 +00:00
|
|
|
* @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
|
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements) = 0;
|
|
|
|
|
1999-02-04 15:17:42 +00:00
|
|
|
/**
|
1999-02-08 16:34:56 +00:00
|
|
|
* Get the number of bytes per pixel for this image
|
1999-02-04 15:17:42 +00:00
|
|
|
* @update - dwc 2/3/99
|
|
|
|
* @return - the number of bytes per pixel
|
|
|
|
*/
|
|
|
|
virtual PRInt32 GetBytesPix() = 0;
|
|
|
|
|
1999-03-30 00:56:35 +00:00
|
|
|
/**
|
|
|
|
* Get whether rows are organized top to bottom, or bottom to top
|
|
|
|
* @update - syd 3/29/99
|
|
|
|
* @return PR_TRUE if top to bottom, else PR_FALSE
|
|
|
|
*/
|
|
|
|
virtual PRBool GetIsRowOrderTopToBottom() = 0;
|
|
|
|
|
1998-04-14 19:56:15 +00:00
|
|
|
/**
|
|
|
|
* Get the width for the pixelmap
|
1999-02-08 16:34:56 +00:00
|
|
|
* @update - dwc 2/1/99
|
|
|
|
* @return The width in pixels for the pixelmap
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual PRInt32 GetWidth() = 0;
|
1998-04-14 19:56:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the height for the pixelmap
|
1999-02-08 16:34:56 +00:00
|
|
|
* @update - dwc 2/1/99
|
|
|
|
* @return The height in pixels for the pixelmap
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual PRInt32 GetHeight() = 0;
|
|
|
|
|
1998-04-14 19:56:15 +00:00
|
|
|
/**
|
|
|
|
* Get a pointer to the bits for the pixelmap, only if it is not optimized
|
1999-02-08 16:34:56 +00:00
|
|
|
* @update - dwc 2/1/99
|
|
|
|
* @return address of the DIB pixel array
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual PRUint8 * GetBits() = 0;
|
|
|
|
|
1998-04-14 19:56:15 +00:00
|
|
|
/**
|
|
|
|
* Get the number of bytes needed to get to the next scanline for the pixelmap
|
1999-02-08 16:34:56 +00:00
|
|
|
* @update - dwc 2/1/99
|
1999-11-04 22:26:57 +00:00
|
|
|
* @return The number of bytes in each scanline
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual PRInt32 GetLineStride() = 0;
|
|
|
|
|
1999-11-04 22:26:57 +00:00
|
|
|
/**
|
|
|
|
* Get whether this image has an alpha mask. Preferable to testing
|
|
|
|
* if GetAlphaBits() is non-null.
|
|
|
|
* @update - sfraser 10/19/99
|
|
|
|
* @return PR_TRUE if the image has an alpha mask, PR_FALSE otherwise
|
|
|
|
*/
|
|
|
|
virtual PRBool GetHasAlphaMask() = 0;
|
|
|
|
|
1998-04-14 19:56:15 +00:00
|
|
|
/**
|
|
|
|
* Get a pointer to the bits for the alpha mask
|
1999-02-08 16:34:56 +00:00
|
|
|
* @update - dwc 2/1/99
|
|
|
|
* @return address of the alpha mask pixel array
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual PRUint8 * GetAlphaBits() = 0;
|
|
|
|
|
1998-05-08 14:24:53 +00:00
|
|
|
/**
|
1999-02-08 16:34:56 +00:00
|
|
|
* Get the number of bytes per scanline for the alpha mask
|
|
|
|
* @update - dwc 2/1/99
|
|
|
|
* @return The number of bytes in each scanline
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual PRInt32 GetAlphaLineStride() = 0;
|
|
|
|
|
1998-04-14 19:56:15 +00:00
|
|
|
/**
|
1999-02-08 16:34:56 +00:00
|
|
|
* Update the nsIImage color table
|
|
|
|
* @update - dwc 2/1/99
|
|
|
|
* @param aFlags Used to pass in parameters for the update
|
|
|
|
* @param aUpdateRect The rectangle to update
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
2004-11-15 04:16:07 +00:00
|
|
|
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsIntRect *aUpdateRect) = 0;
|
2005-03-08 03:44:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get whether this image's region is completely filled with data.
|
|
|
|
* @return PR_TRUE if image is complete, PR_FALSE if image is not yet
|
|
|
|
* complete or broken
|
|
|
|
*/
|
|
|
|
virtual PRBool GetIsImageComplete() = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-14 19:56:15 +00:00
|
|
|
/**
|
|
|
|
* Converted this pixelmap to an optimized pixelmap for the device
|
1999-02-08 16:34:56 +00:00
|
|
|
* @update - dwc 2/1/99
|
|
|
|
* @param aContext The device to optimize for
|
|
|
|
* @return the result of the operation, if NS_OK, then the pixelmap is optimized
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
1998-08-03 04:53:25 +00:00
|
|
|
virtual nsresult Optimize(nsIDeviceContext* aContext) = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-14 19:56:15 +00:00
|
|
|
/**
|
1999-02-08 16:34:56 +00:00
|
|
|
* Get the colormap for the nsIImage
|
|
|
|
* @update - dwc 2/1/99
|
|
|
|
* @return if non null, the colormap for the pixelmap,otherwise the image is not color mapped
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual nsColorMap * GetColorMap() = 0;
|
|
|
|
|
1998-04-14 19:56:15 +00:00
|
|
|
/**
|
1999-02-08 16:34:56 +00:00
|
|
|
* BitBlit the nsIImage to a device, the source can be scaled to the dest
|
|
|
|
* @update - dwc 2/1/99
|
|
|
|
* @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
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
2004-07-18 17:36:03 +00:00
|
|
|
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
|
1998-04-14 19:56:15 +00:00
|
|
|
|
|
|
|
/**
|
1999-02-08 16:34:56 +00:00
|
|
|
* BitBlit the nsIImage to a device, the source and dest can be scaled
|
|
|
|
* @update - dwc 2/1/99
|
1998-04-29 20:28:16 +00:00
|
|
|
* @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
|
1998-04-14 19:56:15 +00:00
|
|
|
*/
|
2004-11-15 04:16:07 +00:00
|
|
|
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface,
|
|
|
|
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
1998-10-30 02:08:25 +00:00
|
|
|
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
|
|
|
|
|
2001-08-09 20:22:39 +00:00
|
|
|
|
|
|
|
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
|
2004-07-18 17:36:03 +00:00
|
|
|
nsIDrawingSurface* aSurface,
|
2001-08-09 20:22:39 +00:00
|
|
|
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
2004-01-16 23:28:51 +00:00
|
|
|
PRInt32 aPadX, PRInt32 aPadY,
|
2001-08-09 20:22:39 +00:00
|
|
|
const nsRect &aTileRect) = 0;
|
|
|
|
|
2001-03-22 04:45:42 +00:00
|
|
|
/**
|
|
|
|
* BitBlit the entire (no cropping) nsIImage to another nsImage, the source and dest can be scaled
|
|
|
|
* @update - saari 03/08/01
|
|
|
|
* @param aDstImage the nsImage to blit to
|
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
NS_IMETHOD DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
|
|
|
|
|
2001-08-28 10:04:59 +00:00
|
|
|
/**
|
|
|
|
* Get the alpha depth for the image mask
|
|
|
|
* @update - lordpixel 2001/05/16
|
|
|
|
* @return the alpha mask depth for the image, ie, 0, 1 or 8
|
|
|
|
*/
|
|
|
|
virtual PRInt8 GetAlphaDepth() = 0;
|
|
|
|
|
1998-06-11 17:33:26 +00:00
|
|
|
/**
|
|
|
|
* Return information about the bits for this structure
|
1999-02-08 16:34:56 +00:00
|
|
|
* @update - dwc 2/1/99
|
|
|
|
* @return a bitmap info structure for the Device Dependent Bits
|
1998-06-11 17:33:26 +00:00
|
|
|
*/
|
|
|
|
virtual void* GetBitInfo() = 0;
|
|
|
|
|
1999-11-04 22:26:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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().
|
|
|
|
*
|
|
|
|
* @update - sfraser 10/18/99
|
|
|
|
* @return error result
|
|
|
|
*/
|
|
|
|
NS_IMETHOD LockImagePixels(PRBool aMaskPixels) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* @update - sfraser 10/18/99
|
|
|
|
* @return error result
|
|
|
|
*/
|
|
|
|
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels) = 0;
|
2006-03-25 00:34:48 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_CAIRO_GFX
|
|
|
|
NS_IMETHOD GetSurface(gfxASurface **aSurface) = 0;
|
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIImage, NS_IIMAGE_IID)
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#endif
|