{
Canvas* pCanvas = null;
result r = E_SUCCESS;
+ Bitmap* pScaledImage = null;
if (IsNeedUpdateImage() == true)
{
r = pCanvas->Clear();
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
- r = pCanvas->DrawBitmap(rect, *pImage->GetInternalBitmap());
+ pScaledImage = ScaledBitmapN(pImage->GetInternalBitmap(), Dimension(rect.width, rect.height));
+ r = GetLastResult();
+ SysTryCatch(NID_UI_CTRL, pScaledImage != null, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = pCanvas->DrawBitmap(Point(0,0), *pScaledImage);
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
r = GetImageVisualElement().SetFlushNeeded();
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ delete pScaledImage;
delete pCanvas;
}
SetNeedUpdateImage(false);
return E_SUCCESS;
CATCH:
+ delete pScaledImage;
delete pCanvas;
return r;
}
return scaledSize;
}
+Bitmap*
+_GalleryCanvas::ScaledBitmapN(Bitmap* pSourceBitmap, Dimension scaledSize)
+{
+ Bitmap* pScaledBitmap = new (std::nothrow) Bitmap();
+ SysTryReturn(NID_UI_CTRL, pScaledBitmap != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to allocate the memory for the Bitmap.");
+
+ FloatRectangle rect(0, 0, pSourceBitmap->GetWidthF(), pSourceBitmap->GetHeightF());
+ int share = 1;
+ int widthShare = rect.width / scaledSize.width;
+ int heightShare = rect.height / scaledSize.height;
+ int power = 0;
+ Dimension realScaleSize = scaledSize;
+
+ result r = pScaledBitmap->Construct(*pSourceBitmap, rect);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ if (widthShare > heightShare)
+ {
+ share = widthShare;
+ }
+ else
+ {
+ share = heightShare;
+ }
+
+
+ while (share > pow(2, (power + 1)))
+ {
+ power++;
+ }
+
+ r = pScaledBitmap->SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ for (; power >= 0; power--)
+ {
+ realScaleSize.width = scaledSize.width * pow(2, power);
+ realScaleSize.height = scaledSize.height * pow(2, power);
+ r = pScaledBitmap->Scale(realScaleSize);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ return pScaledBitmap;
+
+CATCH:
+ delete pScaledBitmap;
+
+ return null;
+}
+
// _GalleryRootCanvas
_GalleryRootCanvas*
delete __pGalleryCoreEvent;
delete __pEmptyGalleryImage;
delete[] __pItemToCanvas;
- delete __pSlideShowTimer;
- __pSlideShowTimer = null;
+
+ if (__pSlideShowTimer != null)
+ {
+ __pSlideShowTimer->Cancel();
+ delete __pSlideShowTimer;
+ __pSlideShowTimer = null;
+ }
}
_GalleryPresenter*
result r = E_SUCCESS;
if (__pSlideShowTimer != null)
{
+ __pSlideShowTimer->Cancel();
delete __pSlideShowTimer;
__pSlideShowTimer = null;
}
return E_SUCCESS;
CATCH:
- delete __pSlideShowTimer;
- __pSlideShowTimer = null;
+ if (__pSlideShowTimer != null)
+ {
+ __pSlideShowTimer->Cancel();
+ delete __pSlideShowTimer;
+ __pSlideShowTimer = null;
+ }
return GetLastResult();
}
void
_GalleryPresenter::StopSlideShowTimer(void)
{
- delete __pSlideShowTimer;
- __pSlideShowTimer = null;
+ if (__pSlideShowTimer != null)
+ {
+ __pSlideShowTimer->Cancel();
+ delete __pSlideShowTimer;
+ __pSlideShowTimer = null;
+ }
__slideShowRepeat = false;
__slideShowPlayCount = 0;