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; }
void CTransparentBitmap::Draw(CFbsBitGc& gc,TInt aX, TInt aY) { // gc.BitBlt(TPoint(aX,aY),iMaskBitmap); if (iSrcBitmap && iMaskBitmap) { TRect sourceRect( TPoint( 0,0 ),iSrcBitmap->SizeInPixels() ); gc.BitBltMasked(TPoint(aX,aY),iSrcBitmap,sourceRect,iMaskBitmap,ETrue); } }
// ----------------------------------------------------------------------------- // CMaskedBitmap::BitBlt // ----------------------------------------------------------------------------- void CMaskedBitmap::BitBlt( CFbsBitGc& aContext, const TPoint& aPoint, const TRect& aSource ) const { if (!(aSource.Width()>0 && aSource.Height()>0)) { return; } if( iBitmap->Handle() ) { if( iMask->Handle() ) { aContext.BitBltMasked( aPoint, iBitmap, aSource, iMask, iInvertMask ); } else { aContext.BitBlt( aPoint, iBitmap, aSource ); } } }
// ----------------------------------------------------------------------------- // 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 ); } } }
// --------------------------------------------------------------------------- // CMMACameraWindow::DrawViewFinderError() // Draws the error message to specified area. // Used in cases when viewfinder is unable to start. // --------------------------------------------------------------------------- // void CMMACameraWindow::DrawViewFinderErrorL( const TInt /*aError*/, const TRect& aDrawRect) { ASSERT(iDirectAccess); TInt dcError = KErrNone; if (!iDirectAccess->IsActive()) { TRAP(dcError, iDirectAccess->StartL()); } TRect drawRect(aDrawRect); if (dcError == KErrNone) { drawRect.Intersection(iClientRect); drawRect.Move(-iWindow->AbsPosition()); CFbsBitGc* directGc = iDirectAccess->Gc(); directGc->SetClippingRect(drawRect); directGc->SetBrushColor(TRgb(128,128,128)); directGc->SetPenColor(TRgb(128,0,0)); directGc->SetBrushStyle(CGraphicsContext::ESolidBrush); directGc->SetPenStyle(CGraphicsContext::ESolidPen); directGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); directGc->DrawRect(drawRect); if (!iErrorIconBitmap || !iErrorIconMaskBitmap) { if (iErrorIconBitmap) { delete iErrorIconBitmap; iErrorIconBitmap = NULL; } if (iErrorIconMaskBitmap) { delete iErrorIconMaskBitmap; iErrorIconMaskBitmap = NULL; } /* AknsUtils::CreateIconL( AknsUtils::SkinInstance(), KAknsIIDQgnIndiCam4Camera, iErrorIconBitmap, iErrorIconMaskBitmap, KCameraAppBitmapFile, EMbmCameraappQgn_indi_cam4_camera, EMbmCameraappQgn_indi_cam4_camera_mask ); */ } //TRect iconRect drawRect.iTl.iX += KErrorIconMargin; drawRect.iTl.iY += KErrorIconMargin; drawRect.iBr.iX -= KErrorIconMargin; drawRect.iBr.iY -= KErrorIconMargin; if (iErrorIconBitmap->SizeInPixels() != drawRect.Size()) { AknIconUtils::SetSize(iErrorIconBitmap, drawRect.Size()); AknIconUtils::SetSize(iErrorIconMaskBitmap, drawRect.Size()); } directGc->BitBltMasked( drawRect.iTl, iErrorIconBitmap, TRect(iErrorIconBitmap->SizeInPixels()), iErrorIconMaskBitmap, EFalse); iDirectAccess->ScreenDevice()->Update(); } }
// --------------------------------------------------------------------------- // 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); } }
void CAknNoteAttributes::SetAnimationBackGroundFrameL() { // R_QGN_GRAF_WAIT_BAR_ANIM case is OK without background frame. if (iAnimation && iAnimationID != R_QGN_GRAF_WAIT_BAR_ANIM) { // Not set background frame, if there is only one frame in animation. CBitmapAnimClientData *animClientData = iAnimation->BitmapAnimData(); if (animClientData != NULL && animClientData->FrameArray().Count() <= 1) { return; } const TDisplayMode displayMode( CCoeEnv::Static()->ScreenDevice()->DisplayMode() ); // Create skinned background frame CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; CleanupStack::PushL(bitmap); User::LeaveIfError( bitmap->Create( iAnimation->Rect().Size(), displayMode ) ); CFbsBitmapDevice* doubleBufferDev = CFbsBitmapDevice::NewL( bitmap ); CleanupStack::PushL(doubleBufferDev); CFbsBitGc* doubleBufferGc = 0; User::LeaveIfError( doubleBufferDev->CreateContext( doubleBufferGc ) ); CleanupStack::PushL(doubleBufferGc); MAknsSkinInstance* skin = AknsUtils::SkinInstance(); MAknsControlContext* cc = iBgContext; AknsDrawUtils::DrawBackground( skin, cc, iNoteControl, *doubleBufferGc, TPoint(0,0), iAnimation->Rect(), KAknsDrawParamDefault ); #if 0 // waitbar background border if ( iAnimationID == R_QGN_GRAF_WAIT_BAR_ANIM ) { CFbsBitmap* frameL = NULL; CFbsBitmap* frameCenter = NULL; CFbsBitmap* frameR = NULL; CFbsBitmap* lMask = NULL; CFbsBitmap* centerMask = NULL; CFbsBitmap* rMask = NULL; AknIconUtils::CreateIconLC( frameL, lMask, KAvkonBitmapFile, EMbmAvkonQgn_graf_bar_frame_side_l, EMbmAvkonQgn_graf_bar_frame_side_l_mask ); AknIconUtils::CreateIconLC( frameCenter, centerMask, KAvkonBitmapFile, EMbmAvkonQgn_graf_bar_frame_center, EMbmAvkonQgn_graf_bar_frame_center_mask); AknIconUtils::CreateIconLC( frameR, rMask, KAvkonBitmapFile, EMbmAvkonQgn_graf_bar_frame_side_r, EMbmAvkonQgn_graf_bar_frame_side_r_mask ); TAknLayoutRect frameGraphicLayout; frameGraphicLayout.LayoutRect( iAnimation->Rect(), AknLayoutScalable_Avkon::wait_border_pane_g1() ); User::LeaveIfError( AknIconUtils::SetSize( frameL, frameGraphicLayout.Rect().Size(), EAspectRatioNotPreserved ) ); frameGraphicLayout.LayoutRect( iAnimation->Rect(), AknLayoutScalable_Avkon::wait_border_pane_g2() ); User::LeaveIfError( AknIconUtils::SetSize( frameCenter, frameGraphicLayout.Rect().Size(), EAspectRatioNotPreserved ) ); frameGraphicLayout.LayoutRect( iAnimation->Rect(), AknLayoutScalable_Avkon::wait_border_pane_g3() ); User::LeaveIfError( AknIconUtils::SetSize( frameR, frameGraphicLayout.Rect().Size(), EAspectRatioNotPreserved ) ); TPoint centerPoint( frameL->SizeInPixels().iWidth, 0 ); TPoint rightPoint( centerPoint.iX + frameCenter->SizeInPixels().iWidth, 0 ); doubleBufferGc->BitBltMasked( TPoint( 0, 0), frameL, TRect( TPoint( 0, 0 ), frameL->SizeInPixels() ), lMask, EFalse ); doubleBufferGc->BitBltMasked( centerPoint, frameCenter, TRect( frameCenter->SizeInPixels() ), centerMask, EFalse ); doubleBufferGc->BitBltMasked( rightPoint, frameR, TRect( frameR->SizeInPixels() ), rMask, EFalse ); CleanupStack::PopAndDestroy( 6 ); if ( iAnimation->BitmapAnimData()->PlayMode() == CBitmapAnimClientData::EPlay ) iAnimation->BitmapAnimData()->SetPlayMode(CBitmapAnimClientData::ECycle); } #endif CleanupStack::PopAndDestroy(2); // doubleBufferGc, doubleBufferDev // finally set background frame CBitmapFrameData* data = CBitmapFrameData::NewL(); data->SetBitmapsOwnedExternally( EFalse ); data->SetBitmap( bitmap ); // Set frame to animation iAnimation->BitmapAnimData()->SetBackgroundFrame( data ); // gets ownership CleanupStack::Pop(bitmap); // bitmap } }