Back to index

lightning-sunbird  0.9+nobinonly
nsImageQt.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Lars Knoll <knoll@kde.org>
00024  *   Zack Rusin <zack@kde.org>
00025  *   John C. Griggs <johng@corel.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either the GNU General Public License Version 2 or later (the "GPL"), or
00029  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #ifndef nsImageQt_h___
00042 #define nsImageQt_h___
00043 
00044 #include "nsIImage.h"
00045 #include "nsRect.h"
00046 
00047 #include <qpixmap.h>
00048 
00049 #undef Bool
00050 
00051 class nsImageQt : public nsIImage
00052 {
00053 public:
00054     nsImageQt();
00055     virtual ~nsImageQt();
00056 
00057     NS_DECL_ISUPPORTS
00058 
00062     virtual nsresult    Init(PRInt32 aWidth, PRInt32 aHeight,
00063                              PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
00064 
00065     virtual PRInt32     GetBytesPix();
00066     virtual PRBool      GetIsRowOrderTopToBottom() {return PR_TRUE;}
00067     virtual PRInt32     GetHeight();
00068     virtual PRInt32     GetWidth();
00069     virtual PRUint8     *GetBits();
00070     virtual PRInt32     GetLineStride();
00071     virtual PRBool      GetHasAlphaMask() {return mAlphaBits != nsnull;}
00072     virtual PRUint8     *GetAlphaBits();
00073     virtual PRInt32     GetAlphaLineStride();
00074 
00075     virtual void ImageUpdated(nsIDeviceContext *aContext,
00076                               PRUint8 aFlags,nsRect *aUpdateRect);
00077     virtual PRBool      GetIsImageComplete();
00078 
00079     virtual nsresult    Optimize(nsIDeviceContext *aContext);
00080 
00081     virtual nsColorMap *GetColorMap();
00082 
00083     NS_IMETHOD Draw(nsIRenderingContext &aContext,
00084                     nsIDrawingSurface* aSurface,
00085                     PRInt32 aX, PRInt32 aY,
00086                     PRInt32 aWidth, PRInt32 aHeight);
00087 
00088     NS_IMETHOD Draw(nsIRenderingContext &aContext,
00089                     nsIDrawingSurface *aSurface,
00090                     PRInt32 aSX, PRInt32 aSY,
00091                     PRInt32 aSWidth, PRInt32 aSHeight,
00092                     PRInt32 aDX, PRInt32 aDY,
00093                     PRInt32 aDWidth, PRInt32 aDHeight);
00094 
00095     NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
00096                         nsIDrawingSurface* aSurface,
00097                         PRInt32 aSXOffset, PRInt32 aSYOffset,
00098                         PRInt32 aPadX, PRInt32 aPadY,
00099                         const nsRect &aTileRect);
00100 
00101     NS_IMETHOD DrawToImage(nsIImage *aDstImage, PRInt32 aDX, PRInt32 aDY,
00102                            PRInt32 aDWidth, PRInt32 aDHeight);
00103 
00104     virtual PRInt8 GetAlphaDepth() { return(mAlphaDepth); }
00105 
00106     virtual void        *GetBitInfo();
00107 
00108     NS_IMETHOD   LockImagePixels(PRBool aMaskPixels);
00109 
00110     NS_IMETHOD   UnlockImagePixels(PRBool aMaskPixels);
00111 
00112 private:
00117     void updatePixmap();
00118 
00119 private:
00120     PRInt32   mWidth;
00121     PRInt32   mHeight;
00122     PRInt32   mDepth;
00123     PRInt32   mRowBytes;
00124     PRUint8   *mImageBits;
00125 
00126     PRInt8    mAlphaDepth;    // alpha layer depth
00127     PRInt16   mAlphaRowBytes; // alpha bytes per row
00128     PRUint8   *mAlphaBits;
00129 
00130 
00131     PRInt8    mNumBytesPixel;
00132 
00133     nsRect    mDecodedRect;   // Keeps track of what part of image has been decoded.
00134 
00135     QPixmap pixmap;
00136     PRBool pixmapDirty;
00137 };
00138 
00139 #endif