2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
20 #include "ImagePanel.h"
22 using namespace Tizen::App;
23 using namespace Tizen::Base;
24 using namespace Tizen::Io;
25 using namespace Tizen::Ui;
26 using namespace Tizen::Ui::Controls;
27 using namespace Tizen::Media;
28 using namespace Tizen::Graphics;
30 ImagePanel::ImagePanel(void)
31 : __pTizenBitmap(null)
35 ImagePanel::~ImagePanel(void)
40 ImagePanel::Initialize(Tizen::Graphics::Rectangle rect)
42 return Panel::Construct(rect);
46 ImagePanel::OnInitializing(void)
49 result r = image.Construct();
50 String filepath = App::GetInstance()->GetAppResourcePath() + L"screen-density-xhigh/tizen.png";
52 __pTizenBitmap = image.DecodeN(filepath, BITMAP_PIXEL_FORMAT_ARGB8888);
58 ImagePanel::OnTerminating(void)
62 delete __pTizenBitmap;
67 ImagePanel::OnDraw(void)
71 Canvas* pCanvas = GetCanvasN();
73 if (pCanvas != null && __pTizenBitmap != null)
75 Rectangle rect = GetBounds();
77 float widthRatio = float(rect.width) / __pTizenBitmap->GetWidth();
78 float heightRatio = float(rect.height) / __pTizenBitmap->GetHeight();
79 float ratio = (widthRatio > heightRatio) ? heightRatio : widthRatio;
81 int height = int(__pTizenBitmap->GetHeight() * ratio);
82 int width = int(__pTizenBitmap->GetWidth() * ratio);
84 r = pCanvas->DrawBitmap(Rectangle((rect.width - width) / 2, (rect.height - height) / 2, width, height), *__pTizenBitmap);
93 ImagePanel::OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
95 Form *pForm = static_cast<Form *>(GetParent());
99 Rectangle clientRect = pForm->GetClientAreaBounds();
100 Rectangle rect(0, 0, clientRect.width, clientRect.height);