www.pudn.com > Example2D.rar > CBitmap.h


/////////////////////////////////////////////////////////////////////////////// 
// 
// CBitmap.h 
// 
// Copyright (c) 2003 Forum Nokia.  All rights reserved. 
// 
// 	 Technology developed by Rocket Science Oy Ltd 
// 
/////////////////////////////////////////////////////////////////////////////// 
 
 
#ifndef __CBITMAP_H__ 
#define __CBITMAP_H__ 
 
// INCLUDE FILES 
#include  
#include  
 
// CLASS DECLARATION 
 
/** 
* CBitmap class handles loading, creation and drawing 
* of bitmap images. 
*/ 
class CBitmap 
	{ 
	public: 
 
		/** 
		* Two-phased constructors. 
		*/ 
		static CBitmap* NewL( const TSize& aSize ); 
		static CBitmap* NewL( TUint16* aData, const TSize& aSize, TDisplayMode aMode ); 
		static CBitmap* NewL( const TFileName& aFileName, TInt aIndex ); 
 
		/** 
		* Destructor. 
		*/	 
		~CBitmap(); 
 
	private: 
 
		/** 
		* Default constructor 
		*/ 
		CBitmap(); 
		 
	public: // New methods 
 
		/** 
		* Destroy current image data 
		*/ 
		void Destroy(); 
 
		/** 
		* Draws image to the given destination. 
		* @param aTarget Target bitmap. 
		* @param aPosition Target position. 
		*/ 
		void Draw( CBitmap& aTarget, const TPoint& aPosition ); 
	 
		/** 
		* Set data pointer of the image 
		* @param aData Target bitmap. 
		*/		 
		void SetData( TUint16* aData ); 
 
		/** 
		* Set the mask color of image. 
		* @param aColor This color will not be drawn. 
		*/		 
		void SetMaskColor( TUint16 aColor ); 
 
		/** 
		* Sets the drawing rectangle of image. 
		* By default the drawing rectangle is size of the image. 
		* @param aRect Area to draw. 
		*/	 
		void SetDrawRect( const TRect& aRect ); 
		 
		/** 
		* Clear image with color. 
		* @param aRgb RGB value of fill color. 
		*/		 
		void Clear( TRgb aRgb ); 
 
		/** 
		* Returns the size of image. 
		* @return TSize Image size. 
		*/ 
		TSize Size(); 
		 
		/** 
		* Sets the size of image. 
		* @param aSize New size for the image. 
		*/ 
		void SetSize(const TSize& aSize); 
 
		/** 
		* Returns the pointer to the image data. 
		* @return TUint16* Image data. 
		*/		 
		TUint16* Data();		 
 
		/** 
		* Returns the color mode of image. 
		* @return TDisplayMode Image color mode. 
		*/ 
		TDisplayMode Mode(); 
 
		/** 
		* Returns current mask color. 
		* @return TUint16 Image mask color. 
		*/ 
		TUint16 MaskColor(); 
 
		/** 
		* Returns current drawing rectangle. 
		* @return TRect Image drawing rectangle. 
		*/ 
		TRect DrawRect(); 
	 
	private: // Data members 
 
		TSize iSize;			/// bitmap size 
		TUint16* iData;			/// bitmap data 
		TDisplayMode iMode;		/// bitmap color mode 
		TUint16 iMaskColor;		/// mask color 
		TRect iDrawRect;		/// draw area 
	}; 
 
#endif 
 
// End of file