Fixed prevent issue
[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.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
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 <GlTypes.h>
23
24 #include "GlCommonUtil.h"
25
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Runtime;
29 using namespace Tizen::Graphics;
30
31 static const int W_DEFAULT_THUMBNAIL = 171;
32 static const int H_DEFAULT_THUMBNAIL = 127;
33 static const int BASE_STANDARD = 1000;
34 static const int FORMAT_TIME = 10;
35 static const String DATETIME_FORMAT = L"%02d:%02d:%02d";
36
37 Bitmap*
38 CommonUtil::GetEmptyThumbnailN(void)
39 {
40         Rectangle mainRect(0, 0, W_DEFAULT_THUMBNAIL, H_DEFAULT_THUMBNAIL);
41         Bitmap* pBitmap = new (std::nothrow) Bitmap();
42         result r = pBitmap->Construct(mainRect);
43         if (r != E_SUCCESS)
44         {
45                 delete pBitmap;
46                 return null;
47         }
48         BufferInfo bufferInfo;
49         pBitmap->Lock(bufferInfo, INFINITE);
50         pBitmap->Unlock();
51         Canvas mainCanvas;
52         mainCanvas.Construct(bufferInfo);
53         mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), mainCanvas.GetBounds());
54         mainCanvas.DrawBitmap(mainRect, *pBitmap);
55         return pBitmap;
56 }
57
58 String
59 CommonUtil::DurationToTimeString(const long duration)
60 {
61         String strTime;
62         DateTime dateTime;
63         dateTime.AddSeconds(duration / BASE_STANDARD);
64         strTime.Format(FORMAT_TIME, DATETIME_FORMAT.GetPointer(), dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
65         return strTime;
66 }