361 } |
366 } |
362 } |
367 } |
363 |
368 |
364 /** |
369 /** |
365 * Constructs an uninitialised Image |
370 * Constructs an uninitialised Image |
366 * |
|
367 * @param aSize The new image's size |
371 * @param aSize The new image's size |
368 */ |
372 */ |
369 MSwtImage* ASwtDisplayBase::NewImageL(const TSize& aSize) |
373 MSwtImage* ASwtDisplayBase::NewImageL(const TSize& aSize) |
370 { |
374 { |
371 return CSwtImage::NewL(*this, aSize, *this); |
375 return CSwtImage::NewL(*this, aSize, *this); |
372 } |
376 } |
373 |
377 |
374 |
|
375 /** |
378 /** |
376 * Constructs an Image with initial data |
379 * Constructs an Image with initial data |
377 * |
|
378 * @param aData The data to construct the image from |
380 * @param aData The data to construct the image from |
379 */ |
381 */ |
380 MSwtImage* ASwtDisplayBase::NewImageFromDataL(const MSwtImageData& aData) |
382 MSwtImage* ASwtDisplayBase::NewImageFromDataL(const MSwtImageData& aData) |
381 { |
383 { |
382 return CSwtImage::NewL(this, aData, this); |
384 return CSwtImage::NewL(this, aData, this); |
383 } |
385 } |
384 |
386 |
|
387 /** |
|
388 * Constructs an image from native theme. |
|
389 * @param aId See TSwtThemeImageId |
|
390 */ |
|
391 MSwtImage* ASwtDisplayBase::NewImageFromThemeL(const TInt aId) |
|
392 { |
|
393 CFbsBitmap* bmp = NULL; |
|
394 CFbsBitmap* mask = NULL; |
|
395 TSize size(0, 0); |
|
396 switch (aId) |
|
397 { |
|
398 case ESwtThemeImageSecurityTrusted: |
|
399 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
400 KAknsIIDQgnIndiMidpTrusted, bmp, mask, |
|
401 AknIconUtils::AvkonIconFileName(), |
|
402 EMbmAvkonQgn_indi_midp_trusted, |
|
403 EMbmAvkonQgn_indi_midp_trusted_mask); |
|
404 size = CSwtLafFacade::GetLayoutRect(CSwtLafFacade::EListSingleGraphicPaneG1, |
|
405 TRect(),0).Rect().Size(); |
|
406 break; |
|
407 case ESwtThemeImageSecurityUntrusted: |
|
408 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
409 KAknsIIDQgnIndiMidpUntrusted, bmp, mask, |
|
410 AknIconUtils::AvkonIconFileName(), |
|
411 EMbmAvkonQgn_indi_midp_untrusted, |
|
412 EMbmAvkonQgn_indi_midp_untrusted_mask); |
|
413 size = CSwtLafFacade::GetLayoutRect(CSwtLafFacade::EListSingleGraphicPaneG1, |
|
414 TRect(),0).Rect().Size(); |
|
415 break; |
|
416 default: |
|
417 return NULL; |
|
418 } |
|
419 |
|
420 if (!bmp) |
|
421 { |
|
422 return NULL; |
|
423 } |
|
424 else |
|
425 { |
|
426 if (size.iWidth > 0) |
|
427 { |
|
428 AknIconUtils::SetSize(bmp, size); |
|
429 } |
|
430 // bmp & mask ownership transferred to returned object |
|
431 return CSwtImage::NewL(*bmp, mask); |
|
432 } |
|
433 } |
|
434 |
|
435 /** |
|
436 * Constructs an Image from another Image. |
|
437 * @param aData The data to construct the image from |
|
438 */ |
|
439 MSwtImage* ASwtDisplayBase::ScaleImageL(const MSwtImage& aSrcImage, |
|
440 const TSize& aDestSize, TBool aKeepAspectRatio) |
|
441 { |
|
442 CFbsBitmap& srcBmp = const_cast<CFbsBitmap&>(aSrcImage.Bitmap()); |
|
443 CFbsBitmap* srcMask = const_cast<CFbsBitmap*>(aSrcImage.MaskBitmap()); |
|
444 |
|
445 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
446 CleanupStack::PushL(bmp); |
|
447 User::LeaveIfError(bmp->Create(aDestSize, srcBmp.DisplayMode())); |
|
448 |
|
449 CFbsBitmap* mask = 0; |
|
450 if (srcMask) |
|
451 { |
|
452 mask = new(ELeave) CFbsBitmap; |
|
453 CleanupStack::PushL(mask); |
|
454 User::LeaveIfError(mask->Create(aDestSize, EGray256)); |
|
455 } |
|
456 |
|
457 CImageScaler* scaler = CImageScaler::NewL(); |
|
458 CleanupStack::PushL(scaler); |
|
459 scaler->Scale(srcBmp, *bmp, aKeepAspectRatio); |
|
460 if (srcMask) |
|
461 { |
|
462 scaler->Scale(*srcMask, *mask, aKeepAspectRatio); |
|
463 } |
|
464 CleanupStack::PopAndDestroy(scaler); |
|
465 if (mask) |
|
466 { |
|
467 CleanupStack::Pop(mask); |
|
468 } |
|
469 CleanupStack::Pop(bmp); |
|
470 |
|
471 // bmp & mask ownership transferred to returned object |
|
472 return CSwtImage::NewL(*bmp, mask); |
|
473 } |
385 |
474 |
386 // |
475 // |
387 // Own internal event methods |
476 // Own internal event methods |
388 // |
477 // |
389 |
478 |