当前位置: 首页>>代码示例>>C++>>正文


C++ CFbsBitmapDevice::CreateContext方法代码示例

本文整理汇总了C++中CFbsBitmapDevice::CreateContext方法的典型用法代码示例。如果您正苦于以下问题:C++ CFbsBitmapDevice::CreateContext方法的具体用法?C++ CFbsBitmapDevice::CreateContext怎么用?C++ CFbsBitmapDevice::CreateContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFbsBitmapDevice的用法示例。


在下文中一共展示了CFbsBitmapDevice::CreateContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetDestinationBitmapL

void CMMABitmapWindow::SetDestinationBitmapL(CFbsBitmap* aBitmap)
{
    CFbsBitmap* bitmap = new(ELeave)CFbsBitmap();
    CleanupStack::PushL(bitmap);
    User::LeaveIfError(bitmap->Duplicate(aBitmap->Handle()));

    // create context for bitmap
    CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(aBitmap);
    CleanupStack::PushL(bitmapDevice);


    CGraphicsContext* bitmapContext = NULL;
    User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));

    CleanupStack::Pop(bitmapDevice);   // bitmapDevice
    CleanupStack::Pop(bitmap);   // bitmap

    delete iBitmap;
    iBitmap = bitmap;
    delete iBitmapDevice;
    iBitmapDevice = bitmapDevice;
    delete iBitmapContext;
    iBitmapContext = bitmapContext;

    if (iDrawRect.IsEmpty())
    {
        iDrawRect.SetSize(iBitmap->SizeInPixels());
    }
}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:29,代码来源:cmmabitmapwindow.cpp

示例2: CreateCheckedBoardL

/**
Create a checked board
@param aPixelFormat The pixel format for create the target bitmap
@param aSize The size of the bitmap
@param aChecksPerAxis Number of checks on X and Y.
 */
CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::CreateCheckedBoardL(TDisplayMode aDisplayMode, TSize aSize, TSize aChecksPerAxis) const
	{
	
	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
	CleanupStack::PushL(bitmap);
	bitmap->Create(aSize, aDisplayMode);
	
	CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
	CleanupStack::PushL(bitmapDevice);
	
	CFbsBitGc* bitGc = NULL;
	User::LeaveIfError(bitmapDevice->CreateContext(bitGc));
	CleanupStack::PushL(bitGc);
	
	bitGc->Clear();
	bitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
	bitGc->SetPenStyle(CGraphicsContext::ENullPen);
	TPoint point(0,0);
	const TSize checkerSize((TReal)aSize.iWidth/aChecksPerAxis.iWidth,(TReal)aSize.iHeight/aChecksPerAxis.iHeight);
	TInt brushColour = 0;
	for(point.iY = 0; point.iY < aSize.iHeight; point.iY += checkerSize.iHeight)
		{
		for(point.iX = 0; point.iX < aSize.iWidth; point.iX += checkerSize.iWidth)
			{
			bitGc->SetBrushColor(KColor16Table[brushColour++ & 0x0F]);
			TRect rect(point, checkerSize);
			bitGc->DrawRect(rect);
			}
		}
	
	CleanupStack::PopAndDestroy(2, bitmapDevice);
	CleanupStack::Pop(bitmap);
	
	return bitmap;
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:41,代码来源:te_graphicsperformanceSuiteStepBase.cpp

示例3: 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);
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:31,代码来源:te_graphicsperformanceSuiteStepBase.cpp

示例4: 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);
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:69,代码来源:talphablend.cpp

示例5: 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;   
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:57,代码来源:AknBitmapMirrorUtils.cpp

示例6: DoProcessMaskL

// ============================================================================
// CIconConverter::DoProcessMaskL()
// process the bitmap mask
//
// @since 3.1
// ============================================================================
void CIconConverter::DoProcessMaskL()
    {
    // we use white to mean transparent at this stage, simply for efficiency
    // since all the canvases we will copy in to begin as white

    if ( iOriginalBitmapMask->Handle() == 0 )
        {
        // Create a mask that shows the whole bitmap as an icon
        // (all black)
        User::LeaveIfError( iOriginalBitmapMask->Create(
            iOriginalBitmap->SizeInPixels(), EGray2 ) );
        CFbsBitmapDevice* device =
            CFbsBitmapDevice::NewL( iOriginalBitmapMask );
        CleanupStack::PushL( device );

        CFbsBitGc* gc;
        User::LeaveIfError( device->CreateContext( gc ) );
        gc->SetBrushStyle( CGraphicsContext::ESolidBrush );
        gc->SetDrawMode( CGraphicsContext::EDrawModePEN );
        gc->SetBrushColor( KRgbBlack );
        // Create a big black image
        gc->Clear();
        delete gc;
        CleanupStack::PopAndDestroy( device );
        }
    else
        {
        // Invert the mask obtained from the PNG
        CFbsBitmapDevice* device =
            CFbsBitmapDevice::NewL( iOriginalBitmapMask );
        CleanupStack::PushL(device);
        CFbsBitGc* gc;
        User::LeaveIfError( device->CreateContext( gc ) );
        gc->SetDrawMode( CGraphicsContext::EDrawModeNOTSCREEN );
        gc->Clear();
        delete gc;
        CleanupStack::PopAndDestroy( device );
        }

    // Scale the icon to the sizes required
    iCurrentSizeIndex = 0;
    DoIconScalingL();
    }
开发者ID:gvsurenderreddy,项目名称:symbiandump-mw4,代码行数:49,代码来源:Iconconverter.cpp

示例7: DoAlphaBlendBitmapsBitmapTestL

/**
Alpha blends two bitmaps together

@param aDisplayMode1 is the source display mode
@param aDisplayMode2 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::DoAlphaBlendBitmapsBitmapTestL(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* sourceUnder  = CreateSoftwareBitmapLC(bitmapSize, aDstMode);
	CFbsBitmap* sourceOver   = CreateSoftwareBitmapLC(bitmapSize, aSrcMode);
	CFbsBitmap* sourceAlpha  = CreateSoftwareBitmapLC(bitmapSize, EGray256);

	VerticalGradientAlphaL(sourceAlpha, TRgb(0x01010101), TRgb(0xfefefefe));
	VerticalGradientAlphaL(sourceUnder, TRgb(0xff000000), TRgb(0x00ffffff));
	VerticalGradientAlphaL(sourceOver, TRgb(0x00ffffff), TRgb(0xff000000));
	RDebug::Printf("DABBBT 2");

	TPoint point(0,0);
	TRect  rect(bitmapSize);
	
	bitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
	bitmapGc->SetBrushColor(TRANSPARENT_BLACK);

	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
	bitmapGc->Clear();
	bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
	bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point);		

	aGc->Activate(aWindow);
	aGc->BitBlt(point, bitmapTarget);
	aGc->Deactivate();
	aSession.Flush();

	iProfiler->InitResults();
	// blend sourceUnder with sourceOver using alpha mask
	for(TInt i=0; i<aNumIterations; i++)
	{
		bitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
		bitmapGc->Clear();
		bitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
		bitmapGc->AlphaBlendBitmaps(point, sourceUnder, sourceOver, rect, point, sourceAlpha, point);
		iProfiler->MarkResultSetL();
	}
	iProfiler->ResultsAnalysis(_L("DoAlphaBlendBitmapsBitmapTestL"), 0, aSrcMode, aDstMode, aNumIterations);
	
	// copy up to screen for sanity check
	BitBlt(aSession, aWindow, aGc, *bitmapTarget);	
	CleanupStack::PopAndDestroy(6, bitmapTarget); // sourceAlpha, sourceOver, sourceUnder, bitmapGc, bitmapDevice, bitmapTarget
	}	
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:63,代码来源:talphablend.cpp

示例8:

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);
		}
	}
开发者ID:kolayuk,项目名称:Tap2Menu,代码行数:16,代码来源:Tap2MenuAppUi.cpp

示例9: 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
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:47,代码来源:AknBitmapMirrorUtils.cpp

示例10: 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;
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:20,代码来源:te_graphicsperformanceSuiteStepBase.cpp

示例11: DoStartSnapshotL

void CTestCamSnapshot::DoStartSnapshotL()
	{
	CFbsBitmap* snapshot = new(ELeave) CFbsBitmap;
	CleanupStack::PushL(snapshot);
	User::LeaveIfError(snapshot->Create(iSnapshotImageRect.Size(), iSnapshotImage->DisplayMode()));
	CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(snapshot);
	CleanupStack::PushL(dev);
	CFbsBitGc* gc = NULL;
	User::LeaveIfError(dev->CreateContext(gc));
	CleanupStack::Pop(dev);
	CleanupStack::Pop(snapshot);
	
	iSnapshot = snapshot;
	iSnapshotDev = dev;
	iSnapshotGc = gc;
		
	iSnapshotActive = ETrue;
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:18,代码来源:test_snapshot.cpp

示例12: DoIconStoreL

// ============================================================================
// CIconConverter::DoIconStoreL()
// Store icon and mask files
//
// @since 3.1
// ============================================================================
void CIconConverter::DoIconStoreL()
    {
    // Store the icon and its mask in temporary files until we are ready
    // to create the final icon

    // Icon is stored at index n, mask at index n+1
    TInt iconIndex = iCurrentSizeIndex * 2;
    TFileName iconFile = *iTempPath;
    GetTempIconName( iconIndex++, iconFile );

    TFileName maskFile = *iTempPath;
    GetTempIconName( iconIndex, maskFile );

    // invert the masks before saving

    CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( iTempBitmapMask );
    CleanupStack::PushL( device );

    CFbsBitGc* gc;
    User::LeaveIfError( device->CreateContext( gc ) );
    gc->SetDrawMode( CGraphicsContext::EDrawModeNOTSCREEN );
    gc->Clear();

    delete gc;
    CleanupStack::PopAndDestroy( device );

    // save the bitmaps
    User::LeaveIfError( iTempBitmap->Save( iconFile ) );
    User::LeaveIfError( iTempBitmapMask->Save( maskFile ) );

    if ( ++iCurrentSizeIndex < iIconSizes->Count() )
        {
        // do the next icon size
        DoIconScalingL();
        }
    else
        {
        DoCreateFinalIconL();
        }

    }
开发者ID:gvsurenderreddy,项目名称:symbiandump-mw4,代码行数:47,代码来源:Iconconverter.cpp

示例13: CreateIconL

//-----------------------------------------------------------------------------
//  CBrowserViewImagesListBox::CreateIconL(
//                                      CFbsBitmap* aBitmap, TBool aShrinkIt )
//-----------------------------------------------------------------------------
//
CGulIcon* CBrowserViewImagesListBox::CreateIconL(
                                        CFbsBitmap* aBitmap, TBool aShrinkIt)
    {
    CGulIcon* icon = NULL;

    // create icon
    if(aShrinkIt)
        {
        CFbsBitmap* bmp = new(ELeave)CFbsBitmap;
        CleanupStack::PushL(bmp);
        User::LeaveIfError(bmp->Create(TSize(42,32), EColor16M));
    
        // create bitmap device
        CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(bmp);
        CleanupStack::PushL(dev);
    
        // create graphics context for bitmap device
        CGraphicsContext* ctx = NULL;
        User::LeaveIfError( dev->CreateContext(ctx) );
        CleanupStack::PushL(ctx);
    
        // calculate aspect ratio
        TSize targetSize = Fit(aBitmap->SizeInPixels(), bmp->SizeInPixels());
        // copy bitmap to temporary bitmap
        ctx->DrawBitmap(TRect(TPoint(0,0), targetSize), aBitmap, TRect(TPoint(0,0), aBitmap->SizeInPixels()));

        CleanupStack::PopAndDestroy(2);   // ctx, dev

        icon = CGulIcon::NewL(bmp); // bmp is owned, no mask used
        CleanupStack::Pop();  // bmp
        delete aBitmap;
        } 
    else 
        {
        icon = CGulIcon::NewL(aBitmap); // bitmap is owned, no mask used
        }

    return icon;
    }
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:44,代码来源:BrowserViewImagesListBox.cpp

示例14: RasterizePictographLineL

TBool CHuiRasterizedTextMesh::RasterizePictographLineL(const TDesC& aTextLine, CFont* aFont, SRasterizedLine & aLineOut)
    {
    if(iUsingPreRasterizedMesh)
        {
        return EFalse;
        }

    // Retrieve the used text style.
    THuiTextStyle* textStyle = CHuiStatic::Env().TextStyleManager().TextStyle(iTextStyleId);
    
    // Calculate line extents and assign it to texture size.
    TSize textureSize = textStyle->LineExtentsL(aTextLine);
	    
    if(textureSize.iWidth == 0 || !iPictographInterface || !iPictographInterface->Interface()->ContainsPictographs(aTextLine))
        {
        // This is an empty string or it does not contain pictographs. We will not rasterize it.
        // Just add a gap.
        aLineOut.iTexture = NULL;
        aLineOut.iGap = textureSize.iHeight;
        return !IsMaxLineCountReached(); 
        }

    // store the actual size to be assigned as the textures logical size
    TSize actualsize(textureSize);

    if (aLineOut.iTexture == NULL)
        {
    // Create a texture for storing the pictographs into.
        aLineOut.iTexture = CHuiTexture::NewL();
        HUI_DEBUG1(_L("CHuiRasterizedTextMesh::RasterizePictographLineL() - Registering self (0x%x) as a texture content observer."), this);        
        // Register one content observer for the first texture that
        // is able to restore all lines in a single run
        if (iLines.Count()==1)
            {
            aLineOut.iTexture->iContentObservers.AppendL(*this);
            }
        aLineOut.iGap = 0;
        }

    // set a name for the texture
    // @todo is this needed, what names to use
    aLineOut.iTexture->SetImageFileNameL(_L("Pictographs"));

    TSize maxTextureSize = aLineOut.iTexture->MaxTextureSize();
    textureSize.iWidth = Min(textureSize.iWidth, maxTextureSize.iWidth);
    textureSize.iHeight = Min(textureSize.iHeight, maxTextureSize.iHeight);

    if((textureSize.iWidth == 0) || (textureSize.iHeight == 0))
        {
        // Cannot draw into this tiny texture, so leave.
        HUI_DEBUG2(_L("CHuiRasterizedTextMesh::RasterizePictographLineL() - texture size was too small to draw into (%i, %i)."), textureSize.iWidth, textureSize.iHeight);
        User::Leave(KErrAbort);
        }

    User::LeaveIfError( iPictographBitmap->Resize(textureSize) );

    CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(iPictographBitmap);
    CleanupStack::PushL(device);

    CFbsBitGc* gc = 0;
    User::LeaveIfError( device->CreateContext(gc) );
    CleanupStack::PushL(gc);

    // Prepare the bitmap for drawing...set drawmode because of EColor16MA mode...
    gc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); 

    TRgb color = KRgbWhite;
    color.SetAlpha(0x00);
    gc->SetBrushColor(color);
    gc->Clear();
    gc->UseFont(aFont);  
    
	// Draw pictorgraphs
    iPictographInterface->Interface()->DrawPictographsInText(
            *gc,
            *aFont,
            aTextLine, TPoint(0, aFont->FontMaxAscent()));

    CleanupStack::PopAndDestroy(gc);
    CleanupStack::PopAndDestroy(device);

    aLineOut.iTexture->UploadL(*iPictographBitmap, NULL, EHuiTextureUploadFlagRetainResolution);
    aLineOut.iTexture->SetSize(actualsize);
    return !IsMaxLineCountReached();
    }
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:85,代码来源:HuiRasterizedTextMesh.cpp

示例15: RetIcon

/*
-------------------------------------------------------------------------------
internal icon re-sizer function
-------------------------------------------------------------------------------
*/   
CGulIcon* CYBRecognizer1::GetListIconL(const TDesC& aFileName,TInt aImage,TInt aMask, TSize aSize)
{
	CGulIcon* RetIcon(NULL);
	TBool OkToAdd(EFalse);
	
	CFbsBitmap* MyBitmap = new(ELeave)CFbsBitmap();
	CleanupStack::PushL(MyBitmap);
	CFbsBitmap* MyMask = new(ELeave)CFbsBitmap();
	CleanupStack::PushL(MyMask);
	
	if(KErrNone == MyBitmap->Load(aFileName,aImage))
	{
		if(KErrNone == MyMask->Load(aFileName,aMask))
		{
			OkToAdd = ETrue;
		}
	}
	
	if(OkToAdd)
	{
		TSize ImgSiz = MyBitmap->SizeInPixels();
		if(aSize.iWidth != ImgSiz.iWidth
		|| aSize.iHeight!= ImgSiz.iHeight)
		{
			CFbsBitmap* TmpBackBitmap = new(ELeave)CFbsBitmap();
			CleanupStack::PushL(TmpBackBitmap);
			
			if(KErrNone == TmpBackBitmap->Create(aSize,MyBitmap->DisplayMode()))
			{	
				CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(TmpBackBitmap);
				CleanupStack::PushL(bitmapDevice);

				CFbsBitGc* graphicsContext = NULL;
				User::LeaveIfError(bitmapDevice->CreateContext(graphicsContext));
				CleanupStack::PushL(graphicsContext);

				graphicsContext->DrawBitmap(TRect(0,0,aSize.iWidth,aSize.iHeight),MyBitmap);
				
				CleanupStack::PopAndDestroy(2);//graphicsContext,bitmapDevice,
			}
			
			CFbsBitmap* TmpBackMask = new(ELeave)CFbsBitmap();
			CleanupStack::PushL(TmpBackMask);
			if(KErrNone == TmpBackMask->Create(aSize,MyMask->DisplayMode()))
			{	
				CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(TmpBackMask);
				CleanupStack::PushL(bitmapDevice);

				CFbsBitGc* graphicsContext = NULL;
				User::LeaveIfError(bitmapDevice->CreateContext(graphicsContext));
				CleanupStack::PushL(graphicsContext);

				graphicsContext->DrawBitmap(TRect(0,0,aSize.iWidth,aSize.iHeight),MyMask);
				
				CleanupStack::PopAndDestroy(2);//graphicsContext,bitmapDevice,
			}
		
			CleanupStack::Pop(2);//TmpBackBitmap, TmpBackMask
			RetIcon = CGulIcon::NewL(TmpBackBitmap, TmpBackMask);
		}
	}
	
	if(!RetIcon && OkToAdd)
	{
		CleanupStack::Pop(2);//MyBitmap, MyMask
		RetIcon = CGulIcon::NewL(MyBitmap, MyMask);
	}
	else
	{
		CleanupStack::PopAndDestroy(2);//MyBitmap, MyMask
	}
		
	return RetIcon;
}
开发者ID:DrJukka,项目名称:Symbian_Codes,代码行数:79,代码来源:YtoolCVcrdRec.cpp


注:本文中的CFbsBitmapDevice::CreateContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。