static void DrawIconL(CWindowGc& aGc, CGulIcon& aIcon, const TJuikLayoutItem& aL, TBool aDoCenter=ETrue) { CALLSTACKITEMSTATIC_N(_CL(""), _CL("DrawIconL")); CFbsBitmap* bmp = aIcon.Bitmap(); CFbsBitmap* mask = aIcon.Mask(); aGc.SetBrushStyle(CGraphicsContext::ENullBrush); // center TInt bmpW = bmp->SizeInPixels().iWidth; TInt areaW = aL.Size().iWidth; TInt dx = 0; TInt dy = 0; if ( aDoCenter && bmpW < areaW ) { dx = (areaW - bmpW) / 2; } TPoint tl = aL.TopLeft(); tl += TPoint(dx,dy); TRect r(TPoint(0,0), bmp->SizeInPixels()); if ( mask ) { aGc.BitBltMasked( tl, bmp, r, mask, ETrue); } else { aGc.BitBlt( tl, bmp, r); } }
// --------------------------------------------------------- // CSymTorrentSearchContainer::ConstructL // EPOC two phased constructor // --------------------------------------------------------- // void CSymTorrentSearchContainer::ConstructL(const TRect& aRect, CSymTorrentAppUi* aAppUi, CSTTorrentManager* aTorrentMgr) { iAppUi=aAppUi; iTorrentMgr=aTorrentMgr; CreateWindowL(); iListBox = new (ELeave) CAknDoubleGraphicStyleListBox(); iListBox->SetMopParent(this); iListBox->ConstructL(this, EAknListBoxSelectionList); iListBox->SetContainerWindowL(*this); iListBox->View()->SetListEmptyTextL(_L("(empty)")); //create scrollbar iListBox->CreateScrollBarFrameL(); iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(1); // must be initialized with the number of icons used by the list! CleanupStack::PushL(icons); #ifdef EKA2 { CGulIcon* chainLinkIcon = CGulIcon::NewL(); CleanupStack::PushL(chainLinkIcon); CFbsBitmap* chainLinkBmp = NULL; CFbsBitmap* chainLinkMask = NULL; AknIconUtils::CreateIconLC(chainLinkBmp, chainLinkMask, KBitmapFile, EMbmSymtorrentChainlink, EMbmSymtorrentChainlink_mask); chainLinkIcon->SetBitmap(chainLinkBmp); chainLinkIcon->SetMask(chainLinkMask); CleanupStack::Pop(2); icons->InsertL(0, chainLinkIcon); CleanupStack::Pop(); } #else { CEikonEnv* eikEnv = CEikonEnv::Static(); icons->AppendL(eikEnv->CreateIconL(KBitmapFile, EMbmSymtorrentChainlink, EMbmSymtorrentChainlink_mask)); } #endif CleanupStack::Pop(icons); // icons iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons); SetRect(aRect); CDesCArray* itemArray = static_cast<CDesCArray*> (iListBox->Model()->ItemTextArray()); itemArray->InsertL(0, _L("0\tFirst line\tSecond line")); ActivateL(); }
void CFileSelectDialog::PostLayoutDynInitL() { CAknListQueryDialog::PostLayoutDynInitL(); CArrayPtr<CGulIcon>* icons; icons=new (ELeave) CAknIconArray(1); CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(),KAknsIIDQgnPropEmpty, AknIconUtils::AvkonIconFileName(),EMbmAvkonQgn_prop_empty,EMbmAvkonQgn_prop_empty_mask); icon->SetBitmapsOwnedExternally(EFalse); icons->AppendL(icon); SetIconArrayL(icons); Update(); Show(); }
/** * Load svg element. */ CGulIcon* CFuiTheme::SvgIconL( TInt aElementId ) { CFbsBitmap* a = NULL; CFbsBitmap* b = NULL; TFileName svgFile; SvgFile( svgFile ); AknIconUtils::CreateIconL( a, b, svgFile, aElementId, aElementId ); CGulIcon* c = CGulIcon::NewL( a, b ); AknIconUtils::PreserveIconData( c->Bitmap() ); AknIconUtils::PreserveIconData( c->Mask() ); TSize contentSize; AknIconUtils::GetContentDimensions( c->Bitmap(), contentSize ); AknIconUtils::SetSize( c->Bitmap(), contentSize ); AknIconUtils::SetSize( c->Mask(), contentSize ); AknIconUtils::DestroyIconData( c->Bitmap() ); AknIconUtils::DestroyIconData( c->Mask() ); iElements.Append( c ); return c; }
// --------------------------------------------------------------------------- // CAppMngr2SisxRuntime::LoadIconsL() // --------------------------------------------------------------------------- // void CAppMngr2SisxRuntime::LoadIconsL( CAknIconArray& aIconArray ) { MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); HBufC* iconFilePath = NULL; iconFilePath = FullBitmapFileNameLC( KAppMngr2SisxIconFileNameMif ); // Icon loading order in must be the same in which SISX icons // are defined in TAppMngr2SisxIcons enum in appmngr2sisx.hrh. // Icon 0: SIS application icon, EQgnMenuAmSis CGulIcon* icon = AknsUtils::CreateGulIconL( skinInstance, KAknsIIDQgnMenuAmSis, *iconFilePath, EMbmAppmngr2sisxQgn_menu_am_sis, EMbmAppmngr2sisxQgn_menu_am_sis_mask ); CleanupStack::PushL( icon ); aIconArray.AppendL( icon ); CleanupStack::Pop( icon ); // Icon 1: DRM expired rights icon, EQgnPropDrmExpLarge icon = AknsUtils::CreateGulIconL( skinInstance, KAknsIIDQgnPropDrmRightsExpLarge, *iconFilePath, EMbmAppmngr2sisxQgn_prop_drm_exp_large, EMbmAppmngr2sisxQgn_prop_drm_exp_large_mask ); CleanupStack::PushL( icon ); aIconArray.AppendL( icon ); CleanupStack::Pop( icon ); // Icon 2: untrusted SIS application, EQgnIndiAmInstNoAdd // Indicator icons are color-skinned as normal icons are // graphically-skinned. CreateColorIconL() must be used to // create color-skinned icon. CFbsBitmap* bitmap = NULL; CFbsBitmap* mask = NULL; AknsUtils::CreateColorIconLC( skinInstance, KAknsIIDQgnIndiAmInstNoAdd, KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG13, bitmap, mask, *iconFilePath, EMbmAppmngr2sisxQgn_indi_am_inst_no_add, EMbmAppmngr2sisxQgn_indi_am_inst_no_add_mask, KRgbBlack ); icon = CGulIcon::NewL( bitmap, mask ); icon->SetBitmapsOwnedExternally( EFalse ); CleanupStack::Pop( 2 ); // bitmap and mask, order may vary CleanupStack::PushL( icon ); aIconArray.AppendL( icon ); CleanupStack::Pop( icon ); CleanupStack::PopAndDestroy( iconFilePath ); }
// ----------------------------------------------------------------------------- // CLandmarksModel::AppendIconL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CLandmarksModel::AppendIconL( const TDesC& aMbmFile, TInt aIconOffset, TInt aMaskOffset) { TAknsItemID aknsItemId = {0,0}; CGulIcon* icon = AknsUtils::CreateGulIconL(NULL, aknsItemId, aMbmFile, aIconOffset, aMaskOffset); CleanupStack::PushL(icon); icon->SetBitmapsOwnedExternally(EFalse); iIconList->AppendL(icon); CleanupStack::Pop(icon); }
void CUiLoftAppView::InsertMyPictureL(TInt aPos) { CMyPicture* picture; // Create a CPicture derived class which will draw our image, depending this Size CGulIcon* icon = iIcons->At(iIcons->Count()-1); CFbsBitmap* bmp = icon->Bitmap(); CFbsBitmap* mask = icon->Mask(); picture = new( ELeave )CMyPicture(TSize(400, 400),*bmp, mask); CleanupStack::PushL(picture); // Prepare the Picture header, which will be instered into the Richtext TPictureHeader header; header.iPicture =TSwizzle<CPicture>(picture); iEditor->RichText()->InsertL( aPos,header); CleanupStack::Pop(); // picture - Richtext take the ownership }
/** * Load svg element and scale it to given size. */ CGulIcon* CFuiTheme::SvgIconL( TInt aElementId, const TSize& aSize ) { CFbsBitmap* a = NULL; CFbsBitmap* b = NULL; TFileName svgFile; SvgFile( svgFile ); AknIconUtils::CreateIconL( a, b, svgFile, aElementId, aElementId ); CGulIcon* c = CGulIcon::NewL( a, b ); AknIconUtils::SetSize( c->Bitmap(), aSize, EAspectRatioNotPreserved ); AknIconUtils::SetSize( c->Mask(), aSize, EAspectRatioNotPreserved ); iElements.Append( c ); return c; }
void CCustomControlList::Draw(CBitmapContext& gc) { TInt x = iDrawPoint.iX + iDisplayPoint.iX; TInt x2 = iDrawPoint.iX + iDisplayPoint.iX + 16; TInt y; TInt dy = iDrawPoint.iY; for (TInt i=0; i<iList->Count(); i++) { if (dy < 0) { dy += iRowHeight; continue; } if (dy >= iDisplaySize.iHeight) { break; } y = dy + iDisplayPoint.iY; pListItemStruct item = (*iList)[i]; CGulIcon* icon = (*iIcons)[item->iIconIndex]; CFbsBitmap* bitmap = icon->Bitmap(); gc.BitBlt(TPoint(x, y), bitmap); gc.UseFont(iFont); if (i!=iSelectIndex) { gc.SetPenColor(iTextColor); // HBufC* text = item->iShowName; // gc.DrawText(*(item->iShowName), TPoint(x2, y)); } else { gc.SetPenColor(iSelectTextColor); // HBufC* text = item->iShowName; // gc.DrawText(*(item->iShowName), TPoint(x2, y)); } y += iFontHeight; gc.DrawText(*(item->iShowName), TPoint(x2, y)); gc.DiscardFont(); dy += iRowHeight; } }
// ----------------------------------------------------------------------------- // CLandmarksModel::CreateIconListL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // CIconList* CLandmarksModel::CreateIconListL() { CIconList* iconList = new (ELeave) CAknIconArray( KGranularity ); CleanupStack::PushL(iconList); // Create the default landmark icon consisting of its image and mask TAknsItemID aknsItemId = {0,0}; CGulIcon* icon = AknsUtils::CreateGulIconL(NULL, aknsItemId, KLandmarksMbmFileName, EMbmLmrefappDefault_lm, EMbmLmrefappDefault_lm_mask); CleanupStack::PushL(icon); icon->SetBitmapsOwnedExternally(EFalse); iconList->AppendL(icon); CleanupStack::Pop(2, iconList); // initialze iIconList. We don't need to delete any possible previous // iIconList since ownership is transferred to calling object. iIconList = iconList; return iIconList; }
EXPORT_C void JuikIcons::SetIconSizeL( CGulIcon& aIcon, const TSize& aSize, TScaleMode aMode) { CALLSTACKITEMSTATIC_N(_CL("JuikIcons"), _CL("SetIconSizeL")); #ifdef __SCALABLEUI_VARIANT__ AknIconUtils::SetSize( aIcon.Bitmap(), aSize, aMode); // no need to set mask size - it's automatically set #else // not __SCALABLEUI_VARIANT__ // do nothing, non-svg icons have correct size when loaded #endif // __SCALABLEUI_VARIANT__ }
// -------------------------------------------------------------------------- // CHomeMediaContainer::UpdatePluginsL // -------------------------------------------------------------------------- // void CHomeMediaContainer::UpdatePluginsL() { __LOG("CHomeMediaContainer::UpdatePluginsL begin"); CEikFormattedCellListBox* listBox = static_cast<CEikFormattedCellListBox*>( &ListBox() ); CArrayPtr<CGulIcon>& icons = *listBox->ItemDrawer()->FormattedCellData()->IconArray(); // Remove old plugins icons TInt pluginIcons = icons.Count() - KNumberOfItemsBeforePlugins; while( pluginIcons ) { pluginIcons--; CGulIcon* icon = icons[ KNumberOfItemsBeforePlugins ]; icons.Delete( KNumberOfItemsBeforePlugins ); delete icon; icon = NULL; } for( TInt i = 0; i < iPluginArray.Count(); i++ ) { //append icon const CGulIcon& icon = iPluginArray[i]->GetIcon(); CGulIcon* copyIcon = CGulIcon::NewL( icon.Bitmap(), icon.Mask() ); CleanupStack::PushL( copyIcon ); // Icon is handled by us, but bitmaps by plugin // when we delete icon, we delete icon only but not bitmaps copyIcon->SetBitmapsOwnedExternally( ETrue ); icons.AppendL( copyIcon ); //Ownership goes to array CleanupStack::Pop( copyIcon ); HBufC* primary = NULL; HBufC* secondary = NULL; // if title of the plugin is not null alloc space for it if ( &(iPluginArray[i]->GetTitle()) ) { primary = ( iPluginArray[i]->GetTitle() ).AllocLC(); } else { primary = KNullDesC().AllocLC(); } // if secondary text of the plugin is not null alloc space for it if ( &(iPluginArray[i]->GetSecondaryText()) ) { secondary = ( iPluginArray[i]->GetSecondaryText() ).AllocLC(); } else { secondary = KNullDesC().AllocLC(); } AddColumnL( KFormatWithTwoStr, i + KNumberOfItemsBeforePlugins, primary, secondary ); // deletion of the texts after they have been set to listbox item CleanupStack::PopAndDestroy( secondary ); CleanupStack::PopAndDestroy( primary ); } __LOG("CHomeMediaContainer::UpdatePluginsL end"); }
void CSpriteSet::RenderSprite(TInt aSpriteType, TInternalSpriteResizeMode aInternalSpriteResizeMode, const TSize& aSourceSize, const TSize& aSpriteSize) { const TInt sourceWidth = aSourceSize.iWidth; const TInt sourceHeight = aSourceSize.iHeight; const TInt spriteWidth = aSpriteSize.iWidth; const TInt spriteHeight = aSpriteSize.iHeight; const TInt numOfHorizAddedLines = spriteHeight-sourceHeight; const TInt numOfVertAddedLines = spriteWidth-sourceWidth; const TPoint posZeroZero(0,0); // cached for repeated use CGulIcon* spriteSetMember = iSourceMembers[aSpriteType]; CFbsBitmap* bitmapToUse = spriteSetMember->Bitmap(); CFbsBitmap* maskToUse = spriteSetMember->Mask(); TRect fromRect; TPoint toPoint; switch(aInternalSpriteResizeMode) { case EHSameVSame: { fromRect.SetRect(0,0,sourceWidth,sourceHeight); iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect); break; } case EHSameVShrink: { const TInt halfSpriteHeight = spriteHeight/2; fromRect.SetRect(0,0,spriteWidth,halfSpriteHeight); iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect); fromRect.SetRect(0,sourceHeight - (halfSpriteHeight) - (spriteHeight%2),sourceWidth,sourceHeight); toPoint.SetXY(0,halfSpriteHeight); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); break; } case EHSameVStretch: { const TInt halfSourceHeight = sourceHeight/2; fromRect.SetRect(0,0,sourceWidth,halfSourceHeight); iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect); fromRect.SetRect(0,halfSourceHeight,sourceWidth,sourceHeight); toPoint.SetXY(0,spriteHeight-(halfSourceHeight)-(sourceHeight%2)); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); for(TInt i = 0; i < numOfHorizAddedLines;i++) { fromRect.SetRect(0,halfSourceHeight,sourceWidth,(halfSourceHeight)+1); toPoint.SetXY(0,(halfSourceHeight)+i); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); } break; } case EHShrinkVSame: { const TInt halfSpriteWidth = spriteWidth/2; fromRect.SetRect(0,0,halfSpriteWidth,spriteHeight); iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect); fromRect.SetRect(sourceWidth - (halfSpriteWidth) - (spriteWidth%2),0,sourceWidth,sourceHeight); toPoint.SetXY(halfSpriteWidth,0); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); break; } case EHShrinkVShrink: { const TInt halfSpriteWidth = spriteWidth/2; const TInt halfSpriteHeight = spriteHeight/2; const TInt spriteHeightModTwo = spriteHeight%2; const TInt spriteWidthModTwo = spriteWidth%2; fromRect.SetRect(0,0,halfSpriteWidth,halfSpriteHeight); iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect); fromRect.SetRect(sourceWidth - (halfSpriteWidth) - (spriteWidthModTwo),0,sourceWidth,halfSpriteHeight); toPoint.SetXY(halfSpriteWidth,0); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); fromRect.SetRect(0,sourceHeight - (halfSpriteHeight) - (spriteHeightModTwo),halfSpriteWidth,sourceHeight); toPoint.SetXY(0,halfSpriteHeight); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); fromRect.SetRect(sourceWidth - (halfSpriteWidth) - (spriteWidthModTwo),sourceHeight - (halfSpriteHeight) - (spriteHeightModTwo),sourceWidth,sourceHeight); toPoint.SetXY(halfSpriteWidth,halfSpriteHeight); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); break; } case EHShrinkVStretch: { const TInt halfSourceHeight = sourceHeight/2; const TInt halfSpriteWidth = spriteWidth/2; const TInt sourceHeightModTwo = sourceHeight%2; const TInt spriteWidthModTwo = spriteWidth%2; fromRect.SetRect(0,0,halfSpriteWidth,halfSourceHeight); iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect); fromRect.SetRect(sourceWidth - (halfSpriteWidth) - (spriteWidthModTwo),0,sourceWidth,halfSourceHeight); toPoint.SetXY(halfSpriteWidth,0); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); fromRect.SetRect(0,sourceHeight - (halfSourceHeight) - (sourceHeightModTwo),halfSpriteWidth,sourceHeight); toPoint.SetXY(0,spriteHeight - (halfSourceHeight) - (sourceHeightModTwo)); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); fromRect.SetRect(sourceWidth - (halfSpriteWidth) - (spriteWidthModTwo),sourceHeight - (halfSourceHeight) - (sourceHeightModTwo),sourceWidth,sourceHeight); toPoint.SetXY(halfSpriteWidth,spriteHeight - (halfSourceHeight) - (sourceHeightModTwo)); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); for(TInt j = 0; j < numOfHorizAddedLines;j++) { fromRect.SetRect(0,spriteHeight - (halfSourceHeight) - (sourceHeightModTwo),spriteWidth,spriteHeight - (halfSourceHeight) - (sourceHeightModTwo)+1); toPoint.SetXY(0,(halfSourceHeight)+j); iMainFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect); iMaskFbsBitGc->BitBlt(toPoint,iTargetMaskBitmap,fromRect); } break; } case EHStretchVSame: { const TInt halfSourceWidth = sourceWidth/2; fromRect.SetRect(0,0,halfSourceWidth,sourceHeight); iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect); fromRect.SetRect(halfSourceWidth,0,sourceWidth,sourceHeight); toPoint.SetXY(spriteWidth-(halfSourceWidth)-(sourceWidth%2),0); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); for(TInt i = 0; i < numOfVertAddedLines;i++) { fromRect.SetRect(halfSourceWidth,0,(halfSourceWidth)+1,sourceHeight); toPoint.SetXY((halfSourceWidth)+i,0); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); } break; } case EHStretchVShrink: { const TInt halfSourceWidth = sourceWidth/2; const TInt halfSpriteHeight = spriteHeight/2; const TInt sourceWidthModTwo = sourceWidth%2; const TInt spriteHeightModTwo = spriteHeight%2; fromRect.SetRect(0,0,halfSourceWidth,halfSpriteHeight); iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect); fromRect.SetRect(sourceWidth - (halfSourceWidth) - (sourceWidthModTwo),0,sourceWidth,halfSpriteHeight); toPoint.SetXY(spriteWidth - (halfSourceWidth) - (sourceWidthModTwo),0); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); fromRect.SetRect(0,sourceHeight - (halfSpriteHeight) - (spriteHeightModTwo),halfSourceWidth,sourceHeight); toPoint.SetXY(0,halfSpriteHeight); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); fromRect.SetRect(sourceWidth - (halfSourceWidth) - (sourceWidthModTwo),sourceHeight - (halfSpriteHeight) - (spriteHeightModTwo),sourceWidth,sourceHeight); toPoint.SetXY(spriteWidth - (halfSourceWidth) - (sourceWidthModTwo),halfSpriteHeight); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); for(TInt j = 0; j < numOfVertAddedLines;j++) { fromRect.SetRect(spriteWidth - (halfSourceWidth) - (sourceWidthModTwo),0,spriteWidth - (halfSourceWidth) - (sourceWidthModTwo)+1,spriteHeight); toPoint.SetXY((halfSourceWidth)+j,0); iMainFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect); iMaskFbsBitGc->BitBlt(toPoint,iTargetMaskBitmap,fromRect); } break; } case EHStretchVStretch: { const TInt halfSourceWidth = sourceWidth/2; const TInt halfSourceHeight = sourceHeight/2; const TInt sourceWidthModTwo = sourceWidth%2; const TInt sourceHeightModTwo = sourceHeight%2; fromRect.SetRect(0,0,halfSourceWidth,halfSourceHeight); iMaskFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect); iMainFbsBitGc->BitBlt(posZeroZero,maskToUse,fromRect); fromRect.SetRect(0,halfSourceHeight,halfSourceWidth,sourceHeight); toPoint.SetXY(0,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo)); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); iMainFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); fromRect.SetRect(halfSourceWidth,0,sourceWidth,halfSourceHeight); toPoint.SetXY(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),0); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); iMainFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); fromRect.SetRect(halfSourceWidth,halfSourceHeight,sourceWidth,sourceHeight); toPoint.SetXY(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),spriteHeight-(halfSourceHeight)-(sourceHeightModTwo)); iMaskFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); iMainFbsBitGc->BitBlt(toPoint,maskToUse,fromRect); for(TInt h = 0; h < numOfVertAddedLines;h++) { fromRect.SetRect(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),0,spriteWidth-(halfSourceWidth)-(sourceWidthModTwo)+1,spriteHeight); toPoint.SetXY((halfSourceWidth)+h,0); iMainFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect); iMaskFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect); } for(TInt m = 0; m < numOfHorizAddedLines;m++) { fromRect.SetRect(0,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo),spriteWidth,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo)+1); toPoint.SetXY(0,(halfSourceHeight)+m); iMaskFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect); } fromRect.SetRect(0,0,halfSourceWidth,halfSourceHeight); iMainFbsBitGc->BitBlt(posZeroZero,bitmapToUse,fromRect); fromRect.SetRect(0,halfSourceHeight,halfSourceWidth,sourceHeight); toPoint.SetXY(0,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo)); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); fromRect.SetRect(halfSourceWidth,0,sourceWidth,halfSourceHeight); toPoint.SetXY(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),0); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); fromRect.SetRect(halfSourceWidth,halfSourceHeight,sourceWidth,sourceHeight); toPoint.SetXY(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),spriteHeight-(halfSourceHeight)-(sourceHeightModTwo)); iMainFbsBitGc->BitBlt(toPoint,bitmapToUse,fromRect); for(TInt j = 0; j < numOfVertAddedLines;j++) { fromRect.SetRect(spriteWidth-(halfSourceWidth)-(sourceWidthModTwo),0,spriteWidth-(halfSourceWidth)-(sourceWidthModTwo)+1,spriteHeight); toPoint.SetXY((halfSourceWidth)+j,0); iMainFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect); } for(TInt i = 0; i < numOfHorizAddedLines;i++) { fromRect.SetRect(0,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo),spriteWidth,spriteHeight-(halfSourceHeight)-(sourceHeightModTwo)+1); toPoint.SetXY(0,(halfSourceHeight)+i); iMainFbsBitGc->BitBlt(toPoint,iTargetBitmap,fromRect); } break; } default: Panic(EEgulPanicInvalidInternalSpriteResizeMode); break; } }
// --------------------------------------------------------- // CDisconnectDlgDialog::PreLayoutDynInitL // --------------------------------------------------------- // void CDisconnectDlgDialog::PreLayoutDynInitL() { CLOG_ENTERFN("CDisconnectDlgDialog::PreLayoutDynInitL"); CAknListQueryDialog::PreLayoutDynInitL(); STATIC_CAST( CEikServAppUi*, CCoeEnv::Static()->AppUi() )->SuppressAppSwitching( ETrue ); CConnectionCArray* connArray = iConnModel->GetConnArray(); // items: application and IAP names CDesCArrayFlat* items = new( ELeave )CDesCArrayFlat( connArray->Count() ); CleanupStack::PushL( items ); // icons: application icons CArrayPtr< CGulIcon >* icons = new( ELeave )CAknIconArray( connArray->Count() ); CleanupStack::PushL( icons ); CGulIcon* iconTemp = NULL; CGulIcon* icon = NULL; TInt count = connArray->Count(); CLOG_WRITEF(_L( "count: %d" ), count ); // Get the info of every connection and initialize the list of dialog for( TInt i = 0; i < count; i++ ) { CConnectionInfo* info = connArray->At( i ); TBool useSharedIcon = EFalse; // Application and IAP name HBufC* listItem = HBufC::NewLC( KListItemTextBuf ); TPtrC iap = info->GetIapNameL(); TPtrC app = info->GetAppNameL( useSharedIcon ); // Application icon iconTemp = info->GetAppIconL( useSharedIcon ); icon = CGulIcon::NewL(); icon->SetBitmapsOwnedExternally( ETrue ); icon->SetBitmap( iconTemp->Bitmap() ); icon->SetMask( iconTemp->Mask() ); icons->AppendL( icon ); listItem->Des().Format( KFormat, i, &iap, &app ); items->AppendL( listItem->Des() ); CleanupStack::PopAndDestroy( listItem ); // listItem } // set new item list SetItemTextArray( items ); // set icon list SetIconArrayL( icons ); // we don't have to take care of delete items SetOwnershipType( ELbmOwnsItemArray ); CleanupStack::Pop( icons ); CleanupStack::Pop( items ); iExpiryTimer = CExpiryTimer::NewL( *this ); iExpiryTimer->Start(); CLOG_LEAVEFN("CDisconnectDlgDialog::PreLayoutDynInitL"); }
/* * 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(); bitmap->UnlockHeap(); delete data; CleanupStack::PopAndDestroy(icon); }