首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Symbian >

怎么用双缓冲的方式显示半透明图片

2012-01-23 
如何用双缓冲的方式显示半透明图片?我想利用CImageDecoder的Create和Convert显示半透明的PNG图片,同时使用

如何用双缓冲的方式显示半透明图片?
我想利用CImageDecoder的Create和Convert显示半透明的PNG图片,同时使用双缓冲的方式,draw的时候用DrawBitmapMasked,有什么办法吗?


如果没有半透明图片,用下面代码创建一个缓冲区是成功的。但显示半透明图片时,Convert的时候生成了一个iBmpMask,这个该怎么搞?我用的SDK是S60 V5,求达人帮忙,折腾好久没解决。


iOffBitmap = new (ELeave) CFbsBitmap();
CleanupStack::PushL(iOffBitmap);

TDisplayMode mode = CAppView::GetView()->GetDisplayMode();

User::LeaveIfError(iOffBitmap->Create(TSize(width, height), mode));
CleanupStack::Pop(iOffBitmap);

iOffDevice = CFbsBitmapDevice::NewL(iOffBitmap);
User::LeaveIfError(iOffDevice->CreateContext(iOffGc));

[解决办法]
http://www.forum.nokia.com/info/sw.nokia.com/id/2335766d-03b8-436a-9886-e39224f32b98/S60_Platform_Image_Converter_Example_v3_0_en.zip.html
[解决办法]
CImageDecoder* iImageDecoder = CImageDecoder::DataNewL(CCoeEnv::Static()->FsSession(),ptr);
TFrameInfo iFrameInfo = iImageDecoder->FrameInfo(0);

CFbsBitmap* iBitmap = new CFbsBitmap();
CFbsBitmap* iBitmapMask = new CFbsBitmap();
CFbsBitmap* newBitmap = new CFbsBitmap();
iBitmap->Create(iFrameInfo.iOverallSizeInPixels, iFrameInfo.iFrameDisplayMode);

TBool transparent = ((iImageDecoder->FrameInfo().iFlags & TFrameInfo::ETransparencyPossible)!=0);
 
if(transparent)
{
iBitmapMask->Create(iFrameInfo.iOverallSizeInPixels, EGray256);
iImageDecoder->Convert(&iStatus, *iBitmap, *iBitmapMask);
}
else
{
iImageDecoder->Convert(&iStatus,*iBitmap);
}
 


iState = EDecoding;
SetActive();
if(!iWait->IsStarted())
{
iWait->Start();
}

newBitmap->Create(iBitmap->SizeInPixels(), EColor64K);
CFbsBitmapDevice* graphicsDevice = CFbsBitmapDevice::NewL(newBitmap);
CFbsBitGc* graphicsContext;
graphicsDevice->CreateContext(graphicsContext);
// Blit the loaded bitmap to the new bitmap (the actual conversion)
TPoint point(0,0);
TSize size2 = iBitmap->SizeInPixels();
TRect rect(point, size2);
if(transparent){
graphicsContext->BitBltMasked(TPoint(0,0), iBitmap, rect/*iBitmap->SizeInPixels()*/, iBitmapMask, EFalse);
//graphicsContext->DrawBitmapMasked(rect,iBitmap,rect,iBitmapMask,ETrue);
}
else
graphicsContext->BitBlt(TPoint(0,0),iBitmap);

热点排行