⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bitmapbitbltmaskcontainer.cpp

📁 symbian S6O 3rd上传图片例题
💻 CPP
字号:
/**
 * 
 * @brief Definition of CBitmapBitBltMaskContainer
 *
 * Copyright (c) EMCC Software Ltd 2003
 * @version 1.0
 */

// INCLUDES

//  Class include
#include "BitmapBitBltMaskContainer.h"

// System includes
#include <fbs.h> //CFbsBitmap
#include <aknutils.h>

// User include
#include <Bitmap.mbg> // Bitmap enumeration

// CONSTANTS
_LIT(KBitmapPath, "\\system\\apps\\Bitmap\\Bitmap.mbm");
const TInt KTopLeftX = 10;
const TInt KTopLeftY = 40;
const TInt KSizeWidth = 154;
const TInt KSizeHeight = 90;

// CONSTANTS

// ================= MEMBER FUNCTIONS =======================

/**

 * Symbian OS 2 phase constructor.
 * Constructs the CBitmapBitBltMaskContainer using the NewLC method, popping
 * the constructed object from the CleanupStack before returning it.
 * 
 * @param aRect The rectangle for this window
 * @return The newly constructed CBitmapBitBltMaskContainer
 */

CBitmapBitBltMaskContainer* CBitmapBitBltMaskContainer::NewL(const TRect& aRect)
	{
	CBitmapBitBltMaskContainer* self = CBitmapBitBltMaskContainer::NewLC(aRect);
	CleanupStack::Pop(self);
	return self;
	}

/**
 * Symbian OS 2 phase constructor.
 * Constructs the CBitmapBitBltMaskContainer using the constructor and ConstructL 
 * method, leaving the constructed object on the CleanupStack before returning it.
 * 
 * @param aRect The rectangle for this window
 * @return The newly constructed CBitmapBitBltMaskContainer
 */

CBitmapBitBltMaskContainer* CBitmapBitBltMaskContainer::NewLC(const TRect& aRect)
	{
	CBitmapBitBltMaskContainer* self = new (ELeave) CBitmapBitBltMaskContainer;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	return self;
	}

/**
 * Symbian OS 2nd phase constructor.  Creates a Window for the control to draw to.
 * Creates two bitmaps, one displayed image and one masking image. Illustrates use of
 * the CFbsBitmap::Load() function
 *
 * @param aRect The rectangle for this window
 */
 
void CBitmapBitBltMaskContainer::ConstructL(const TRect& aRect)
	{
	CreateWindowL();	
	SetRect(aRect);
	
	TFileName bitmapFile (KBitmapPath);
	User::LeaveIfError (CompleteWithAppPath (bitmapFile));

	iBitmap = new (ELeave) CFbsBitmap();
	User::LeaveIfError(iBitmap->Load(bitmapFile, EMbmBitmapBitbltbitmap));

	iMask = new (ELeave) CFbsBitmap();
	User::LeaveIfError(iMask->Load(bitmapFile, EMbmBitmapBitmapmask));

	ActivateL();
	}

/** 
 * Destructor.  
 */

CBitmapBitBltMaskContainer::~CBitmapBitBltMaskContainer()
	{
	delete iBitmap;
	delete iMask;
	}

/**
 * Called by the framework to draw this control.  Clears the area specified
 * by aRect, creates a TPoint object for the top left of the image, draws bitmap using
 * masked blitting. This allows for true shape of bitmap to be displayed and not be limited
 * to being rectangular.
 *
 * @param aRect in which to draw
 */

void CBitmapBitBltMaskContainer::Draw(const TRect& aRect) const
	{
	CWindowGc& gc = SystemGc();
	gc.Clear(aRect);
	TPoint topLeft(KTopLeftX, KTopLeftY);
	gc.BitBltMasked(topLeft, iBitmap, TRect(TPoint(0,0), TSize(KSizeWidth, KSizeHeight)), iMask, ETrue);
	}

// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -