本文整理汇总了C++中CFbsBitGc::BitBlt方法的典型用法代码示例。如果您正苦于以下问题:C++ CFbsBitGc::BitBlt方法的具体用法?C++ CFbsBitGc::BitBlt怎么用?C++ CFbsBitGc::BitBlt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFbsBitGc
的用法示例。
在下文中一共展示了CFbsBitGc::BitBlt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateBitmapL
CFbsBitmap* AknBitmapMirrorUtils::CreateBitmapL(CFbsBitmap* aSourceBitmap, TInt aMirrorDirection)
{
User::LeaveIfNull(aSourceBitmap);
CFbsBitmap* destinationBitmap = new (ELeave) CFbsBitmap();
CleanupStack::PushL(destinationBitmap);
TSize sourceBitmapSize = aSourceBitmap->SizeInPixels();
TRect sourceRect = TRect(TPoint(0,0), sourceBitmapSize);
TSize destinationBitmapSize(sourceRect.Width(), sourceRect.Height());
User::LeaveIfError(destinationBitmap->Create(destinationBitmapSize, aSourceBitmap->DisplayMode()));
CFbsBitmapDevice* destinationDevice = CFbsBitmapDevice::NewL( destinationBitmap );
CleanupStack::PushL(destinationDevice);
CFbsBitGc* destinationGc;
User::LeaveIfError( destinationDevice->CreateContext( destinationGc ) );
switch (aMirrorDirection)
{
case EAknVerticalMirroring:
{
TRect sourceBitmapBlittingRect( sourceRect.iTl.iX,sourceRect.iTl.iY,sourceRect.iBr.iX,sourceRect.iTl.iY + 1 );
for ( TInt yPos=destinationBitmapSize.iHeight-1; yPos >= 0; yPos-- )
{
destinationGc->BitBlt( TPoint(0,yPos), aSourceBitmap, sourceBitmapBlittingRect );
sourceBitmapBlittingRect.iTl.iY++;
sourceBitmapBlittingRect.iBr.iY++;
}
break;
}
case EAknHorizontalMirroring:
{
TRect sourceBitmapBlittingRect( sourceRect.iTl.iX,sourceRect.iTl.iY,sourceRect.iTl.iX + 1,sourceRect.iBr.iY );
for ( TInt xPos=destinationBitmapSize.iWidth-1; xPos >= 0; xPos-- )
{
destinationGc->BitBlt( TPoint(xPos,0), aSourceBitmap, sourceBitmapBlittingRect );
sourceBitmapBlittingRect.iTl.iX++;
sourceBitmapBlittingRect.iBr.iX++;
}
break;
}
default:
{
destinationGc->BitBlt( TPoint(0,0), aSourceBitmap, sourceRect );
break;
}
}
delete destinationGc;
CleanupStack::Pop(2); // destinationBitmap, destinationDevice
delete destinationDevice;
return destinationBitmap;
}
示例2: DoBitBltAlphaBitmapTestL
/**
Bitblt test
@param aSrcMode is the source display mode
@param aDstMode is the destination display mode
@param aSession is the windows server session
@param aWindow is a reference to the window
@param aGc is the graphics context of the window
@param aNumIterations is the number of iterations to run the test
*/
void CAlphaBlendTest::DoBitBltAlphaBitmapTestL(TDisplayMode aSrcMode,TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
{
const TSize bitmapSize = aWindow.Size();
CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
CleanupStack::PushL(bitmapDevice);
CFbsBitGc* bitmapGc = NULL;
User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));
CleanupStack::PushL(bitmapGc);
CFbsBitmap* source = CreateSoftwareBitmapLC(bitmapSize, aSrcMode);
CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(bitmapSize, EGray256); // match size to src
VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe));
VerticalGradientAlphaL(source, TRgb(0x00000000), TRgb(0xffffffff));
TPoint point(0,0);
bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
bitmapGc->Clear();
bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
bitmapGc->BitBlt(point, source);
aGc->Activate(aWindow);
aGc->BitBlt(point, bitmapTarget);
aGc->Deactivate();
aSession.Flush();
iProfiler->InitResults();
for(TInt i=0; i<aNumIterations; i++)
{
bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
bitmapGc->Clear();
bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
bitmapGc->BitBlt(point, source);
iProfiler->MarkResultSetL();
}
iProfiler->ResultsAnalysis(_L("DoBitBltAlphaBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations);
// copy up to screen for sanity check
aGc->Activate(aWindow);
aGc->BitBlt(TPoint(), bitmapTarget);
aGc->Deactivate();
CleanupStack::PopAndDestroy(5, bitmapTarget); //sourceAlpha, source, bitmapGc, bitmapDevice, bitmapTarget
}
示例3: CompareScreenContentWithTestBitmapL
TBool CTestContainer::CompareScreenContentWithTestBitmapL(const CBitmapFrameData& aBkgdFrame, const CBitmapFrameData& aFrame1, const TPoint& aPos)
{
TSize size = aFrame1.Bitmap()->SizeInPixels();
// Create test bitmap for comparison
CFbsBitmap* testBitmap = new (ELeave) CFbsBitmap;
CleanupStack::PushL(testBitmap);
User::LeaveIfError( testBitmap->Create(size, iEikonEnv->DefaultDisplayMode()));
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(testBitmap);
CleanupStack::PushL(bitmapDevice);
CFbsBitGc* bitmapGc = CFbsBitGc::NewL();
CleanupStack::PushL(bitmapGc);
bitmapGc->Activate(bitmapDevice);
// Blit the background bitmap
bitmapGc->BitBlt(aPos, aBkgdFrame.Bitmap());
// Blit the frame bitmap with mask
bitmapGc->BitBltMasked(aPos, aFrame1.Bitmap(), size, aFrame1.Mask(), ETrue);
// Create bitmap and blit the screen contents into it for comparing it with test bitmap created above
TRect rect(aPos,size);
CFbsBitmap* scrBitmap = new (ELeave) CFbsBitmap;
CleanupStack::PushL(scrBitmap);
User::LeaveIfError(scrBitmap->Create(size, iEikonEnv->DefaultDisplayMode()) );
User::LeaveIfError( iEikonEnv->ScreenDevice()->CopyScreenToBitmap(scrBitmap,rect) );
TBool ret=CompareBitmapsL(testBitmap,scrBitmap);
CleanupStack::PopAndDestroy(4); //scrBitmap, bitmapGc, bitmapDevice, testBitmap
return ret;
}
示例4: CopyBitmapL
/**
Copy a bitmap into another bitmap (generally in a different displaymode)
tiles destination bitmap with source
*/
void CTe_graphicsperformanceSuiteStepBase::CopyBitmapL(CFbsBitmap* aDst, CFbsBitmap* aSrc)
{
TSize srcSize = aSrc->SizeInPixels();
TSize dstSize = aDst->SizeInPixels();
CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(aDst);
CleanupStack::PushL(dev);
CFbsBitGc* gc = NULL;
if ( 0 == dev->CreateContext(gc) )
{
CleanupStack::PushL(gc);
TPoint point;
gc->SetBrushColor(TRANSPARENT_BLACK);
gc->SetBrushStyle(CGraphicsContext::ENullBrush);
gc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
gc->Clear();
gc->SetDrawMode(CGraphicsContext::EDrawModePEN);
for(point.iY=0; point.iY<dstSize.iHeight; point.iY+=srcSize.iHeight)
{
for(point.iX=0; point.iX<dstSize.iWidth; point.iX+=srcSize.iWidth)
{
gc->BitBlt(point, aSrc);
}
}
CleanupStack::PopAndDestroy(gc);
}
CleanupStack::PopAndDestroy(dev);
}
示例5: End
/**
Completes a pass of this render stage.
*/
void CTestRenderStage::End()
{
CFbsBitGc* gc = iBackBuffer->GetBitGcCurrent();
gc->SetPenSize(TSize(2,2));
gc->SetPenColor(KRgbRed);
gc->DrawLine(TPoint(50,0),TPoint(0,50));
gc->SetPenColor(KRgbGreen);
gc->DrawLine(TPoint(60,0),TPoint(0,60));
if (Next())
{
gc = Next()->Begin();
const TRegion* region = iScreenRedraw->AnimationRegion();
if(region && !region->IsEmpty() && !region->CheckError())
{
if (iBackBuffer->Observer())
iBackBuffer->Observer()->BeforeUpdate(*iBackBuffer,*region);
gc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
gc->SetClippingRegion(region);
gc->BitBlt(-iScreenConfig->ScaledOrigin(),iBackBuffer->GetBitmap());
gc->SetDrawMode(CGraphicsContext::EDrawModePEN);
gc->CancelClipping();
if (iBackBuffer->Observer())
iBackBuffer->Observer()->AfterUpdate(*iBackBuffer,*region);
}
Next()->End();
}
}
示例6: LoadPartialBitmapL
void AknBitmapMirrorUtils::LoadPartialBitmapL(CFbsBitmap* aBitmap, const TDesC& aFileName,TInt32 aId, TRect aRect, TBool aMirrorHorizontally)
{
CFbsBitmap* destinationBitmap = aBitmap;
User::LeaveIfNull(destinationBitmap);
CFbsBitmap* sourceBitmap = new (ELeave) CFbsBitmap();
CleanupStack::PushL(sourceBitmap);
User::LeaveIfError(sourceBitmap->Load(aFileName, aId, ETrue));
TSize sourceBitmapSize = sourceBitmap->SizeInPixels();
TRect sourceRect = TRect(aRect);
if (sourceRect == KWholeBitmapRect)
{
sourceRect.iTl.iX = 0;
sourceRect.iTl.iY = 0;
sourceRect.iBr.iX = sourceBitmapSize.iWidth;
sourceRect.iBr.iY = sourceBitmapSize.iHeight;
}
TSize destinationBitmapSize(sourceRect.Width(), sourceRect.Height());
User::LeaveIfError(destinationBitmap->Create(destinationBitmapSize, sourceBitmap->DisplayMode()));
CFbsBitmapDevice* destinationDevice = CFbsBitmapDevice::NewL( destinationBitmap );
CleanupStack::PushL(destinationDevice);
CFbsBitGc* destinationGc;
User::LeaveIfError( destinationDevice->CreateContext( destinationGc ) );
if (aMirrorHorizontally)
{
TRect sourceBitmapBlittingRect( sourceRect.iTl.iX,sourceRect.iTl.iY,sourceRect.iTl.iX + 1,sourceRect.iBr.iY );
for ( TInt xPos=destinationBitmapSize.iWidth-1; xPos >= 0; xPos-- )
{
destinationGc->BitBlt( TPoint(xPos,0), sourceBitmap, sourceBitmapBlittingRect );
sourceBitmapBlittingRect.iTl.iX++;
sourceBitmapBlittingRect.iBr.iX++;
}
}
else
{
destinationGc->BitBlt( TPoint(0,0), sourceBitmap, sourceRect );
}
delete destinationGc;
CleanupStack::PopAndDestroy(2); // sourceBitmap, destinationDevice
}
示例7: DoDrawBitmapL
/**
Draws a stretched bitmap with or without a mask.
@param aUseMask set to ETrue to use a alpha mask. Normally used for 16MU display modes that do not store the alpha.
@param aSrcMode is the source display mode
@param aDstMode is the destination display mode
@param aSession is the windows server session
@param aWindow is a reference to the window
@param aGc is the graphics context of the window
@param aNumIterations is the number of iterations to run the test
*/
void CAlphaBlendTest::DoDrawBitmapL(TBool aUseMask, TDisplayMode aSrcMode, TDisplayMode aDstMode, RWsSession& aSession, RWindow& aWindow, CWindowGc* aGc, TInt aNumIterations)
{
const TSize bitmapSize = aWindow.Size();
// Construct target bitmap.
CFbsBitmap* bitmapTarget = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmapTarget);
CleanupStack::PushL(bitmapDevice);
// Construct GC.
CFbsBitGc* bitmapGc = NULL;
User::LeaveIfError(bitmapDevice->CreateContext(bitmapGc));
CleanupStack::PushL(bitmapGc);
// Construct source bitmap.
TSize smallerSize(bitmapSize.iWidth/2, bitmapSize.iHeight/2);
CFbsBitmap* source = CreateSoftwareBitmapLC(smallerSize, aSrcMode);
VerticalGradientAlphaL(source, TRgb(0x00000000), TRgb(0xffffffff));
CFbsBitmap* sourceAlpha = CreateSoftwareBitmapLC(smallerSize, EGray256); // match size to src
VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe));
bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
bitmapGc->SetBrushColor(TRANSPARENT_BLACK);
bitmapGc->Clear();
bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
aGc->Activate(aWindow);
TPoint point(0,0);
bitmapGc->BitBlt(point, bitmapTarget);
aGc->Deactivate();
aSession.Flush();
TBuf <20> testName;
if (!aUseMask)
{
testName=_L("DrawBitmap");
iProfiler->InitResults();
for(int i=0; i<aNumIterations; i++)
{
bitmapGc->DrawBitmap(TRect(point, bitmapSize), source);
iProfiler->MarkResultSetL();
}
}
else
{
testName=_L("DrawBitmapMasked");
iProfiler->InitResults();
for(int i=0; i<aNumIterations; i++)
{
bitmapGc->DrawBitmapMasked(TRect(point, bitmapSize), source,TRect(point, smallerSize), sourceAlpha, EFalse);
iProfiler->MarkResultSetL();
}
}
INFO_PRINTF4(_L("%S(Stretched) with src = %S, dst = %S"), &testName, &ColorModeName(aSrcMode), &ColorModeName(aDstMode));
iProfiler->ResultsAnalysis(testName, 0, aSrcMode, aDstMode, aNumIterations);
// copy up to screen for sanity check
BitBlt(aSession, aWindow, aGc, *bitmapTarget);
CleanupStack::PopAndDestroy(5, bitmapTarget);
}
示例8: DrawBitmap
// CFepLayoutChoiceList::DrawBitmap
// Draw bitmap helper function.
// (other items were commented in a header).
// ---------------------------------------------------------------------------
//
void CFepLayoutChoiceList::DrawBitmap(const TRect& aDestRect, const TRect& aSrcRect,
CFbsBitmap* aBmp, TBool aFast)
{
CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
if( aFast )
{
gc->BitBlt(aDestRect.iTl, aBmp, aSrcRect);
}
else
{
gc->DrawBitmap(aDestRect, aBmp, aSrcRect);
}
}
示例9:
void CTap2MenuAppUi::CopyBitmapL(CFbsBitmap *aSource, CFbsBitmap *aTarget)
{
if(aSource != NULL && aTarget != NULL)
{
if(aSource->SizeInPixels() != aTarget->SizeInPixels() || aSource->DisplayMode() != aTarget->DisplayMode())
{User::Leave(KErrArgument);}
CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(aTarget);
CleanupStack::PushL(device);
CFbsBitGc* gc = NULL;
User::LeaveIfError(device->CreateContext(gc));
CleanupStack::PushL(gc);
gc->BitBlt(TPoint(0, 0), aSource);
CleanupStack::PopAndDestroy(gc);
CleanupStack::PopAndDestroy(device);
}
}
示例10: CopyBitmapL
class CFbsBitmap* WFBitmapUtil::CopyBitmapL(class CFbsBitmap* aBitmap)
{
if (!aBitmap) {
return NULL;
}
class CFbsBitmap* copiedBitmap = new (ELeave) CFbsBitmap();
copiedBitmap->Create(aBitmap->SizeInPixels(), aBitmap->DisplayMode());
CFbsBitmapDevice* fbsdev = CFbsBitmapDevice::NewL(copiedBitmap);
CleanupStack::PushL(fbsdev);
CFbsBitGc* fbsgc = CFbsBitGc::NewL();
CleanupStack::PushL(fbsgc);
fbsgc->Activate(fbsdev);
fbsgc->BitBlt(TPoint(0,0),aBitmap);
CleanupStack::PopAndDestroy(2);
return copiedBitmap;
}
示例11: CopyIntoNewBitmapL
/**
Copy a source bitmap into a new bitmap with the specified display mode
*/
CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::CopyIntoNewBitmapL(CFbsBitmap* aSrc, TDisplayMode aDisplayMode)
{
CFbsBitmap* dstBmp = new(ELeave) CFbsBitmap;
CleanupStack::PushL(dstBmp);
TInt ret=dstBmp->Create(aSrc->SizeInPixels(), aDisplayMode);
User::LeaveIfError(ret);
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(dstBmp);
CleanupStack::PushL(bitmapDevice);
CFbsBitGc* gc;
ret = bitmapDevice->CreateContext(gc);
User::LeaveIfError(ret);
CleanupStack::PushL(gc);
gc->BitBlt(TPoint(0,0), aSrc);
CleanupStack::PopAndDestroy(2, bitmapDevice); // gc, bitmapDevice
CleanupStack::Pop(dstBmp);
return dstBmp;
}
示例12: CopyScreenToBitmapL
/**
Auxilary function called to Copy the screen to bitmap (mbm) file.
@param aHashIndex contains hashID. Bitmap is created with the aHashIndex as name
*/
EXPORT_C void CTHashReferenceImages::CopyScreenToBitmapL(const TDesC& aHashIndex)
{
CFbsBitmap *bitmap = new(ELeave)CFbsBitmap();
CleanupStack::PushL(bitmap);
User::LeaveIfError(bitmap->Create(iBitmapDevice->SizeInPixels(), iBitmapDevice->DisplayMode()));
TRect rect = TRect(iBitmapDevice->SizeInPixels());
CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(bitmap);
CleanupStack::PushL(device);
CFbsBitGc *gc;
User::LeaveIfError(device->CreateContext(gc));
gc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
gc->BitBlt(TPoint(), iBitmap, rect);
TFileName mbmFile;
mbmFile.Format(iPath->Des(), &aHashIndex);
bitmap->Save(mbmFile);
delete gc;
CleanupStack::PopAndDestroy(2);
}
示例13: BitBlt
// -----------------------------------------------------------------------------
// CMaskedBitmap::BitBlt
// -----------------------------------------------------------------------------
void CMaskedBitmap::BitBlt( CFbsBitGc& aContext, const TPoint& aPoint ) const
{
TSize s(iBitmap->SizeInPixels());
if (!(s.iWidth>0 && s.iHeight>0))
{
return;
}
if( iBitmap->Handle() )
{
if( iMask->Handle() )
{
aContext.BitBltMasked( aPoint, iBitmap, s, iMask, iInvertMask );
}
else
{
aContext.BitBlt( aPoint, iBitmap, s );
}
}
}
示例14: CreateBitmapOptimizedL
CFbsBitmap* AknBitmapMirrorUtils::CreateBitmapOptimizedL(CFbsBitmap* aSourceBitmap, TInt aMirrorDirection)
{
// Check if displaymode is optimized, fallback to non-optimized version if not.
TBool fallback = ETrue;
TDisplayMode displayMode = aSourceBitmap->DisplayMode();
switch( displayMode )
{
case EGray256:
case EColor256:
case EColor4K:
case EColor64K:
fallback = EFalse;
break;
default:
fallback = ETrue;
}
// Check if mirroring mode is supported, fallback to non-optimized version if not.
if ((aMirrorDirection != EAknVerticalMirroring) && (aMirrorDirection != EAknHorizontalMirroring))
{
fallback = ETrue;
}
if( fallback )
return CreateBitmapL(aSourceBitmap, aMirrorDirection);
// Prepare destination bitmap
User::LeaveIfNull(aSourceBitmap);
CFbsBitmap* destinationBitmap = new (ELeave) CFbsBitmap();
CleanupStack::PushL(destinationBitmap);
TSize sourceBitmapSize = aSourceBitmap->SizeInPixels();
TRect sourceRect = TRect(TPoint(0,0), sourceBitmapSize);
TSize destinationBitmapSize(sourceRect.Width(), sourceRect.Height());
User::LeaveIfError(destinationBitmap->Create(destinationBitmapSize, aSourceBitmap->DisplayMode()));
// Check source, if rom bitmap or compressed then create uncompressed ram bitmap
TBool srcTemporary = EFalse;
if( aSourceBitmap->IsRomBitmap() )
{
srcTemporary = ETrue;
}
// Heap lock for FBServ large chunk to prevent background
// compression of aSrcBitmap after if IsCompressedInRAM returns EFalse
aSourceBitmap->LockHeapLC( ETrue ); // fbsheaplock
TBool fbsHeapLock = ETrue;
if( aSourceBitmap->IsCompressedInRAM() )
{
srcTemporary = ETrue;
}
if( aSourceBitmap->ExtendedBitmapType() != KNullUid )
{
srcTemporary = ETrue;
}
CFbsBitmap* realSource = aSourceBitmap;
if( srcTemporary )
{
CleanupStack::PopAndDestroy(); // fbsheaplock
fbsHeapLock = EFalse;
realSource = new (ELeave) CFbsBitmap();
CleanupStack::PushL( realSource );
User::LeaveIfError( realSource->Create( sourceBitmapSize, aSourceBitmap->DisplayMode() ) );
CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL( realSource );
CleanupStack::PushL( dev );
CFbsBitGc* gc = NULL;
User::LeaveIfError( dev->CreateContext( gc ) );
CleanupStack::PushL( gc );
gc->BitBlt( TPoint(0,0), aSourceBitmap );
CleanupStack::PopAndDestroy(2); // dev, gc
}
// Heap lock for FBServ large chunk is only needed with large bitmaps.
if (!fbsHeapLock)
{
if ( realSource->IsLargeBitmap() || destinationBitmap->IsLargeBitmap() )
{
destinationBitmap->LockHeapLC( ETrue ); // fbsheaplock
}
else
{
CleanupStack::PushL( (TAny*)NULL );
}
}
TUint32* srcAddress = realSource->DataAddress();
TUint32* trgAddress = destinationBitmap->DataAddress();
if ( displayMode == EColor4K || displayMode == EColor64K )
{
TInt srcScanLen16 = CFbsBitmap::ScanLineLength(sourceBitmapSize.iWidth, displayMode) / 2;
TInt trgScanLen16 = CFbsBitmap::ScanLineLength(destinationBitmapSize.iWidth, displayMode) / 2;
TInt srcScanLen32 = CFbsBitmap::ScanLineLength(sourceBitmapSize.iWidth, displayMode) / 4;
TInt trgScanLen32 = CFbsBitmap::ScanLineLength(destinationBitmapSize.iWidth, displayMode) / 4;
switch (aMirrorDirection)
//.........这里部分代码省略.........
示例15: ConstructL
/*
* Landmark objects will make use of an SVG file for rendering (demo purposes)
*/
void CLMXObject::ConstructL()
{
_LIT(KIconFile, "\\resource\\apps\\Landmarks_0x2002E1AF.mif");
CGulIcon* icon = CreateIconL(KIconFile, EMbmLandmarks_0x2002e1afIcon, EMbmLandmarks_0x2002e1afIcon_mask);
CleanupStack::PushL(icon);
CFbsBitmap* bitmap = icon->Bitmap(); // Ownership NOT transferred
CFbsBitmap* mask = icon->Mask(); // Ownership NOT transferred
// Always expect 16M bitmap to make conversion to GL_RGBA easier
if (bitmap->DisplayMode() != EColor16M)
{
bitmap = new(ELeave) CFbsBitmap;
CleanupStack::PushL(bitmap);
User::LeaveIfError(bitmap->Create(icon->Bitmap()->SizeInPixels(), EColor16M));
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
CleanupStack::PushL(bitmapDevice);
CFbsBitGc* bitmapContext = 0;
User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));
CleanupStack::PushL(bitmapContext);
bitmapContext->BitBlt(TPoint(0, 0), icon->Bitmap());
CleanupStack::PopAndDestroy(2, bitmapDevice);
icon->SetBitmap(bitmap); // Ownership transferred
CleanupStack::Pop(bitmap);
}
// Always expect 256 mask to make conversion to GL_RGBA easier
if (mask->DisplayMode() != EGray256)
{
mask = new(ELeave) CFbsBitmap;
CleanupStack::PushL(mask);
User::LeaveIfError(mask->Create(icon->Mask()->SizeInPixels(), EGray256));
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(mask);
CleanupStack::PushL(bitmapDevice);
CFbsBitGc* bitmapContext = 0;
User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));
CleanupStack::PushL(bitmapContext);
bitmapContext->BitBlt(TPoint(0, 0), icon->Mask());
CleanupStack::PopAndDestroy(2, bitmapDevice);
icon->SetMask(mask); // Ownership transferred
CleanupStack::Pop(mask);
}
// Now bitmap and mask point to either original or converted bitmaps,
// and ownership belongs to icon
const TSize bitmapSize = bitmap->SizeInPixels();
// sizeof(TUint32) == sizeof(RGBA)
const TInt dataSize = bitmapSize.iWidth * bitmapSize.iHeight * sizeof(TUint32);
TUint8* data = new(ELeave) TUint8[dataSize];
// Perform copy and conversion from BGR(A) to RGB(A)
bitmap->LockHeap();
mask->LockHeap();
// TODO: Alpha component removed, as it seems to be corrupted from
// subsequent reads from SVG file
TUint8* rgb = reinterpret_cast<TUint8*>(bitmap->DataAddress());
// TUint8* alpha = reinterpret_cast<TUint8*>(mask->DataAddress());
for(TInt i = 0, j = 0; i < dataSize; i += 4, j += 3)
{
data[i + 0] = rgb[j + 2];
data[i + 1] = rgb[j + 1];
data[i + 2] = rgb[j + 0];
data[i + 3] = 0xc0; //alpha[i / 4];
}
// Generate OpenGL texture
::glGenTextures(1, &iTextureId);
::glBindTexture(GL_TEXTURE_2D, iTextureId);
::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bitmapSize.iWidth, bitmapSize.iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
mask->UnlockHeap();
//.........这里部分代码省略.........