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; }
static CFbsBitmap* createBlitCopy(CFbsBitmap* bitmap) { CFbsBitmap *copy = q_check_ptr(new CFbsBitmap); if(!copy) return 0; if (copy->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) { delete copy; copy = 0; return 0; } CFbsBitmapDevice* bitmapDevice = 0; CFbsBitGc *bitmapGc = 0; QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(copy)); QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL()); bitmapGc->Activate(bitmapDevice); bitmapGc->BitBlt(TPoint(), bitmap); delete bitmapGc; delete bitmapDevice; return copy; }
// CFepLayoutChoiceList::DrawChoiceListBackground // Draw choice list background. // (other items were commented in a header). // --------------------------------------------------------------------------- // void CFepLayoutChoiceList::DrawChoiceListBackground(const TRect& aRect)//, TBool aDrawBorder) { if( iBackgroundSkinID.iMajor != EAknsMajorNone && iBackgroundSkinID.iMinor != EAknsMinorNone ) { //draw bitmap DrawOpaqueMaskBackground( aRect ); TRect rtInnerRect( aRect ); rtInnerRect.Shrink( 1, 1 ); CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); gc->Activate( BitmapDevice() ); AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), *gc, aRect, rtInnerRect, iBackgroundSkinID, KAknsIIDDefault ); } else { //draw bitmap DrawOpaqueMaskBackground(); //front bitmaps------- DrawBackground(); } }
void CEmTubeSplashViewContainer::ConstructL(const TRect& aRect) { iAlpha = KAlphaMax; iAppUi = STATIC_CAST(CEmTubeAppUi*, CEikonEnv::Static()->EikAppUi()); CreateWindowL(); TSize size( KBitmapSize, KBitmapSize ); CFbsBitmap *bmp = AknIconUtils::CreateIconL( KBitmapFileName, EMbmOpenvideohubLogo_white ); CleanupStack::PushL( bmp ); AknIconUtils::SetSize( bmp, size ); iBitmap = new (ELeave) CFbsBitmap(); iBitmap->Create( size, EColor16MU ); CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL( iBitmap ); CleanupStack::PushL( bitmapDevice ); CFbsBitGc* bitmapGc = CFbsBitGc::NewL(); CleanupStack::PushL( bitmapGc ); bitmapGc->Activate( bitmapDevice ); bitmapGc->DrawBitmap( size, bmp ); CleanupStack::PopAndDestroy( bitmapGc ); CleanupStack::PopAndDestroy( bitmapDevice ); CleanupStack::PopAndDestroy( bmp ); iTmpBitmap = new (ELeave) CFbsBitmap; iTmpBitmap->Create( TSize(KBitmapSize, KBitmapSize), EColor16MU ); SetRect(aRect); iClientRect = aRect; ActivateL(); SetExtentToWholeScreen(); iAppUi->StopDisplayingPopupToolbar(); iFadeTimer = CEmTubeTimeOutTimer::NewL( *this ); iFadeTimer->After( KFadePeriod, ECommandFadeIn ); iTimer = CEmTubeTimeOutTimer::NewL( *this ); iTimer->After( KSplashTime, ECommandFinish ); #ifdef __S60_50__ MTouchFeedback* feedback = MTouchFeedback::Instance(); if ( feedback ) { feedback->EnableFeedbackForControl( this, ETrue ); } #endif }
// ----------------------------------------------------------------------------- // CMaskedBitmap::TileInBitmapRect // ----------------------------------------------------------------------------- void CMaskedBitmap::TileInBitmapRect( CFbsBitGc& gc, const TRect& bmpRect, const TPoint& srcPt ) { if (!HasMask()) { TRAP_IGNORE( CFbsBitGc* copy = CFbsBitGc::NewL(); CleanupStack::PushL( copy ); copy->Activate( (CFbsDevice*) gc.Device() ); copy->CopySettings( gc ); copy->UseBrushPattern(iBitmap); copy->SetPenStyle(CGraphicsContext::ENullPen); copy->SetBrushStyle(CGraphicsContext::EPatternedBrush); copy->SetBrushOrigin(srcPt); copy->DrawRect(bmpRect); copy->DiscardBrushPattern(); CleanupStack::PopAndDestroy( copy ); );
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; }
// ----------------------------------------------------------------------------- // CAknsAlEffectContext::CreateIfNeededL // ----------------------------------------------------------------------------- // void CAknsAlEffectContext::CreateIfNeededL( const TInt aLayerIndex, const TInt aLayerStatus, const TBool aInitialize ) { if( ( aLayerIndex < 0 ) || ( aLayerIndex >= KAknsAlEffectContextLayerN ) ) { User::Leave( KAknsRlErrBadLayerIndex ); } /*lint -save -e661 */ // Index is boundary checked above if( iLayers[aLayerIndex].iRGBBitmap && iLayers[aLayerIndex].iAlphaBitmap ) return; if( iLayers[aLayerIndex].iRGBBitmap || iLayers[aLayerIndex].iAlphaBitmap ) User::Leave( KAknsRlErrInternalState ); TSize size = LayerSize(); CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); CleanupStack::PushL( bitmap ); User::LeaveIfError( bitmap->Create( size, iRgbMode ) ); CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL( bitmap ); CleanupStack::PushL( dev ); CFbsBitGc* gc = CFbsBitGc::NewL(); CleanupStack::PushL( gc ); gc->Activate( dev ); iLayers[aLayerIndex].iRGBBitmap = bitmap; iLayers[aLayerIndex].iRGBDevice = dev; iLayers[aLayerIndex].iRGBGc = gc; CleanupStack::Pop(3); // gc, dev, bitmap bitmap = new (ELeave) CFbsBitmap(); CleanupStack::PushL( bitmap ); User::LeaveIfError( bitmap->Create( size, EGray256 ) ); dev = CFbsBitmapDevice::NewL( bitmap ); CleanupStack::PushL( dev ); gc = CFbsBitGc::NewL(); CleanupStack::PushL( gc ); gc->Activate( dev ); iLayers[aLayerIndex].iAlphaBitmap = bitmap; iLayers[aLayerIndex].iAlphaDevice = dev; iLayers[aLayerIndex].iAlphaGc = gc; CleanupStack::Pop(3); // gc, dev, bitmap if( aInitialize ) { switch( aLayerStatus ) { case KAknsRlLayerRGBOnly: iLayers[aLayerIndex].iRGBGc->SetBrushColor( KRgbBlack ); iLayers[aLayerIndex].iRGBGc->Clear(); iLayers[aLayerIndex].iAlphaGc->SetBrushColor( KRgbWhite ); iLayers[aLayerIndex].iAlphaGc->Clear(); break; default: iLayers[aLayerIndex].iRGBGc->SetBrushColor( KRgbBlack ); iLayers[aLayerIndex].iRGBGc->Clear(); iLayers[aLayerIndex].iAlphaGc->SetBrushColor( KRgbBlack ); iLayers[aLayerIndex].iAlphaGc->Clear(); break; } } /*lint -restore */ }//lint !e661 Layer index is boundary checked
// --------------------------------------------------------------------------- // CAknDiscreetPopupDrawer::CreatePopupBitmap // --------------------------------------------------------------------------- // void CAknDiscreetPopupDrawer::CreatePopupBitmapL( const TRect& aRect ) { delete iPopupBitmap; iPopupBitmap = NULL; // create a bitmap to draw to CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap; CleanupStack::PushL( bitmap ); bitmap->Create( aRect.Size(), CCoeEnv::Static()->ScreenDevice()->DisplayMode() ); CFbsBitGc* fbsBitGc = CFbsBitGc::NewL(); CleanupStack::PushL( fbsBitGc ); CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL( bitmap ); CleanupStack::PushL( bmpDevice ); fbsBitGc->Activate( bmpDevice ); // draw background of the popup MAknsSkinInstance* skin = AknsUtils::SkinInstance(); AknsDrawUtils::DrawFrame( skin, *fbsBitGc, aRect, aRect, KAknsIIDQsnFrPopupPreview, KAknsIIDDefault, KAknsDrawParamDefault ); // Draw the texts TRgb textColor( EikonEnv()->ControlColor( EColorControlText, *iControl ) ); if ( iAction ) { fbsBitGc->SetUnderlineStyle( EUnderlineOn ); AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG3 ); } else { AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG55 ); } fbsBitGc->SetPenColor( textColor ); DrawTexts( fbsBitGc ); fbsBitGc->SetUnderlineStyle( EUnderlineOff ); // draw the icon if ( iIcon && iIcon->Bitmap() && iIcon->Mask() ) { fbsBitGc->BitBltMasked( iIconRect.iTl, iIcon->Bitmap(), iIcon->Bitmap()->SizeInPixels(), iIcon->Mask(), EFalse ); } else if( iIcon && iIcon->Bitmap() ) { fbsBitGc->BitBlt( iIconRect.iTl, iIcon->Bitmap() ); } CleanupStack::PopAndDestroy( bmpDevice ); CleanupStack::PopAndDestroy( fbsBitGc ); CleanupStack::Pop( bitmap ); iPopupBitmap = bitmap; }
EXPORT_C void CBubbleCtrl::Draw() { if(!AbleToDraw() || iFreeze ) //|| !iShowing ) { return; } CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); //mask bitmaps DrawOpaqueMaskBackground(); TRect rect = Rect(); TRect innerRect = rect; if ( ( iLeftDiff == 0 ) && ( iTopDiff == 0 ) && ( iRightDiff == 0 ) && ( iBottomDiff == 0 ) ) { innerRect.Shrink( KShrinkSize, 0 ); } else { innerRect.iTl.iX = innerRect.iTl.iX + iLeftDiff; innerRect.iTl.iY = innerRect.iTl.iY + iTopDiff; innerRect.iBr.iX = innerRect.iBr.iX - iRightDiff; innerRect.iBr.iY = innerRect.iBr.iY - iBottomDiff; } // ----- draw bitmaps ----- gc->Activate( BitmapDevice() ); //gc->Clear(rect); // Draw background if ( iBgSkinId.iMajor ) { AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), *gc, rect, innerRect, iBgSkinId, KAknsIIDDefault ); } else if( iFirstBmpId.iMajor && iMiddleBmpId.iMajor && iLastBmpId.iMajor ) { AknPenInputDrawUtils::Draw3PiecesFrame( AknsUtils::SkinInstance(), *gc, rect, innerRect, iFirstBmpId, iMiddleBmpId, iLastBmpId); } else { DrawBackground(); } if ( iForgroundBmp ) { if( iForgroundBmp->SizeInPixels() != innerRect.Size() ) { AknIconUtils::SetSize( iForgroundBmp, innerRect.Size(), EAspectRatioNotPreserved ); } TRect srcRect( TPoint( 0, 0 ), iForgroundBmp->SizeInPixels() ); if( iForgroundBmpMask ) { if( iForgroundBmpMask->SizeInPixels() != innerRect.Size() ) { AknIconUtils::SetSize( iForgroundBmpMask, innerRect.Size(), EAspectRatioNotPreserved); } gc->BitBltMasked( innerRect.iTl, iForgroundBmp, srcRect, iForgroundBmpMask, EFalse); } else { gc->BitBlt( innerRect.iTl, iForgroundBmp, srcRect ); } } if ( iText ) { gc->SetBrushStyle( CGraphicsContext::ENullBrush ); TAknLayoutText textLayout; textLayout.LayoutText(Rect(), iTextFormat); TRgb color( KRgbBlack ); // sane default for nonskinned case if ( AknsUtils::AvkonSkinEnabled() ) { AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), color, KAknsIIDQsnTextColors, iTextColorIndex ); } textLayout.DrawText(*gc, *iText, EFalse, color); } }
EXPORT_C void AknsUtils::CreateColorIconLC( MAknsSkinInstance* aInstance, const TAknsItemID& aID, const TAknsItemID& aColorID, const TInt aColorIndex, CFbsBitmap*& aBitmap, CFbsBitmap*& aMask, const TDesC& aFilename, const TInt aFileBitmapId, const TInt aFileMaskId, const TRgb aDefaultColor, const TSize& aSize, const TScaleMode aScaleMode ) { CFbsBitmap* bitmap = NULL; CFbsBitmap* mask = NULL; CreateIconLC( aInstance, aID, bitmap, mask, aFilename, aFileBitmapId, aFileMaskId ); // (2) TRgb color = aDefaultColor; // Return value intentionally ignored GetCachedColor( aInstance, color, aColorID, aColorIndex ); if( AknIconUtils::IsMifIcon( bitmap ) ) { AknIconUtils::SetIconColor( bitmap, color ); aBitmap = bitmap; aMask = mask; } else // Create Own Icon { CFbsBitmap* colorBitmap = new (ELeave) CFbsBitmap(); CleanupStack::PushL( colorBitmap ); // (3) TSize size = mask->SizeInPixels(); User::LeaveIfError( colorBitmap->Create( size, CEikonEnv::Static()->ScreenDevice()->DisplayMode() ) ); CFbsBitmapDevice* colorBmpDev = CFbsBitmapDevice::NewL( colorBitmap ); CleanupStack::PushL( colorBmpDev ); // (4) User::LeaveIfError( colorBmpDev->Resize( size ) ); CFbsBitGc* colorBmpGc = CFbsBitGc::NewL(); CleanupStack::PushL( colorBmpGc ); // (5) colorBmpGc->Activate( colorBmpDev ); colorBmpGc->SetBrushColor( color ); colorBmpGc->SetPenStyle( CGraphicsContext::ENullPen ); colorBmpGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); colorBmpGc->DrawRect( TRect( TPoint(0,0), size ) ); CleanupStack::PopAndDestroy( 2 ); // colorBmpGc, colorBmpDev (3) CleanupStack::Pop( 3 ); // colorBmp, bitmap, mask (0) delete bitmap; // We don't know the order, must destroy manually aBitmap = colorBitmap; aMask = mask; // These are both safe CleanupStack::PushL( aBitmap ); // (1) CleanupStack::PushL( aMask ); // (2) } if( aSize.iWidth>=0 ) { // Set the size User::LeaveIfError( AknIconUtils::SetSize( aBitmap, aSize, aScaleMode ) ); } }
// CFepLayoutChoiceList::DrawItem // Draw a choice list item. // (other items were commented in a header). // --------------------------------------------------------------------------- // void CFepLayoutChoiceList::DrawItem(const TRect& aRect, const CFepLayoutChoiceList::SItem& aItem, TBool aErase, TBool aFocus) { if(iWndControl) return; CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); if( aErase ) { SetBorderColor( BkColor() ); //DrawChoiceListBackground( aRect );//, EFalse); } if( aFocus ) { //draw focus bitmap TRect rtFocusRect(iItemFocusRect); TRect rtFocusInBmp(TPoint(0,0), iItemFocusRect.Size()); rtFocusRect.Move(aRect.iTl); TRect rtInnerRect( rtFocusRect ); rtInnerRect.Shrink( 5, 5 ); if( iSubItemSkinID.iMajor != EAknsMajorNone && iSubItemSkinID.iMinor != EAknsMinorNone) { gc->Activate( BitmapDevice() ); AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), *gc, rtFocusRect, rtInnerRect, iSubItemSkinID, KAknsIIDDefault ); } else { //mask bitmaps------- gc->Activate( MaskBitmapDevice() ); if( iItemFocusBmpMask ) { DrawBitmap(rtFocusRect, rtFocusInBmp, iItemFocusBmpMask, iItemFocusBmpMask->SizeInPixels() == rtFocusInBmp.Size()); } //front bitmaps------- gc->Activate( BitmapDevice() ); if( iItemFocusBmp ) { DrawBitmap(rtFocusRect, rtFocusInBmp, iItemFocusBmp, iItemFocusBmp->SizeInPixels() == rtFocusInBmp.Size()); } } } //draw text if (iFont) { gc->UseFont(iFont); gc->SetBrushStyle( CGraphicsContext::ENullBrush ); gc->SetPenColor(iFontColor); gc->SetPenStyle(CGraphicsContext::ESolidPen); gc->DrawText(aItem.iText, aRect, iBaseline, CGraphicsContext::ELeft, iMargin); gc->DiscardFont(); } }