3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
21 #include "ImagePanel.h"
23 using namespace Tizen::App;
24 using namespace Tizen::Base;
25 using namespace Tizen::Io;
26 using namespace Tizen::Ui;
27 using namespace Tizen::Ui::Controls;
28 using namespace Tizen::Media;
29 using namespace Tizen::Graphics;
31 ImagePanel::ImagePanel(void)
32 : __pTizenBitmap(null)
36 ImagePanel::~ImagePanel(void)
41 ImagePanel::Initialize(Tizen::Graphics::Rectangle rect)
43 return Panel::Construct(rect);
47 ImagePanel::OnInitializing(void)
50 result r = image.Construct();
51 String filepath = App::GetInstance()->GetAppResourcePath() + L"screen-density-xhigh/tizen.png";
53 __pTizenBitmap = image.DecodeN(filepath, BITMAP_PIXEL_FORMAT_ARGB8888);
59 ImagePanel::OnTerminating(void)
63 delete __pTizenBitmap;
68 ImagePanel::OnDraw(void)
72 Canvas* pCanvas = GetCanvasN();
74 if (pCanvas != null && __pTizenBitmap != null)
76 Rectangle rect = GetBounds();
78 float widthRatio = float(rect.width) / __pTizenBitmap->GetWidth();
79 float heightRatio = float(rect.height) / __pTizenBitmap->GetHeight();
80 float ratio = (widthRatio > heightRatio) ? heightRatio : widthRatio;
82 int height = int(__pTizenBitmap->GetHeight() * ratio);
83 int width = int(__pTizenBitmap->GetWidth() * ratio);
85 r = pCanvas->DrawBitmap(Rectangle((rect.width - width) / 2, (rect.height - height) / 2, width, height), *__pTizenBitmap);
94 ImagePanel::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
96 Form *pForm = static_cast<Form *>(GetParent());
100 Rectangle clientRect = pForm->GetClientAreaBounds();
101 Rectangle rect(0, 0, clientRect.width, clientRect.height);