Tizen 2.1 base
[apps/osp/Gallery.git] / src / GlCommonUtil.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                GlCommonUtil.cpp
19  * @brief               This is the implementation file for CommonUtil class.
20  */
21
22 #include "GlCommonUtil.h"
23
24 using namespace Tizen::Base;
25 using namespace Tizen::Graphics;
26
27 static const int W_DEFAULT_THUMBNAIL = 158;
28 static const int H_DEFAULT_THUMBNAIL = 158;
29 static const int BASE_STANDARD = 1000;
30 static const int FORMAT_TIME = 10;
31 static const String DATETIME_FORMAT = L"%02d:%02d";
32
33 Bitmap*
34 CommonUtil::GetEmptyThumbnailN(void)
35 {
36         Rectangle mainRect(0, 0, W_DEFAULT_THUMBNAIL, H_DEFAULT_THUMBNAIL);
37         Bitmap* pBitmap = new (std::nothrow) Bitmap();
38         pBitmap->Construct(mainRect);
39         BufferInfo bufferInfo;
40         pBitmap->Lock(bufferInfo, INFINITE);
41         pBitmap->Unlock();
42         Canvas mainCanvas;
43         mainCanvas.Construct(bufferInfo);
44         mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), mainCanvas.GetBounds());
45         mainCanvas.DrawBitmap(mainRect, *pBitmap);
46         return pBitmap;
47 }
48
49 String
50 CommonUtil::DurationToTimeString(long duration)
51 {
52         String strTime;
53         DateTime dateTime;
54         dateTime.AddSeconds( duration / BASE_STANDARD);
55         strTime.Format(FORMAT_TIME, DATETIME_FORMAT.GetPointer(), dateTime.GetMinute(), dateTime.GetSecond());
56         return strTime;
57 }