Merge "N_SE-43925" into tizen_2.2
[apps/osp/Gallery.git] / src / GlThumbnailInfo.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                GlThumbnailInfo.cpp
19  * @brief               This is the implementation file for ThumbnailInfo class.
20  */
21
22 #include <FGraphics.h>
23 #include "GlThumbnailInfo.h"
24 #include "GlTypes.h"
25
26 using namespace Tizen::Base;
27 using namespace Tizen::Content;
28 using namespace Tizen::Graphics;
29
30 ThumbnailInfo::ThumbnailInfo(void)
31         : __pBitmap(null)
32         , __contentType(CONTENT_TYPE_IMAGE)
33         , __duration(0)
34 {
35 }
36
37 ThumbnailInfo::~ThumbnailInfo(void)
38 {
39 }
40
41 void
42 ThumbnailInfo::Construct(const ContentId& contentId, const String& filePath,
43                 const Bitmap& bitmap, const ContentType contentType, const long duration)
44 {
45         __contentId = contentId;
46         __filePath = filePath;
47         __pBitmap = CloneBitmapN(bitmap);
48         __contentType = contentType;
49         __duration = duration;
50 }
51
52 ContentId
53 ThumbnailInfo::GetContentId(void) const
54 {
55         return __contentId;
56 }
57
58 String
59 ThumbnailInfo::GetFilePath(void) const
60 {
61         return __filePath;
62 }
63
64 void
65 ThumbnailInfo::SetFilePath(const String& filePath)
66 {
67         if (&filePath == null)
68         {
69                 __filePath = EMPTY_SPACE;
70         }
71         else
72         {
73                 __filePath = filePath;
74         }
75 }
76
77 Bitmap*
78 ThumbnailInfo::GetBitmapN(void) const
79 {
80         return CloneBitmapN(*__pBitmap);
81 }
82
83 void
84 ThumbnailInfo::SetBitmap(const Bitmap& bitmap)
85 {
86         __pBitmap = CloneBitmapN(bitmap);
87 }
88
89 ContentType
90 ThumbnailInfo::GetContentType(void) const
91 {
92         return __contentType;
93 }
94
95 void
96 ThumbnailInfo::SetContentType(ContentType contentType)
97 {
98         __contentType = contentType;
99 }
100
101 long
102 ThumbnailInfo::GetDuration(void) const
103 {
104         return __duration;
105 }
106
107 void
108 ThumbnailInfo::SetDuration(long duration)
109 {
110         __duration = duration;
111 }
112
113 Bitmap*
114 ThumbnailInfo::CloneBitmapN(const Bitmap& bitmap) const
115 {
116         Bitmap* pResultBitmap = null;
117         if (&bitmap != null)
118         {
119                 Rectangle mainRect(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
120                 Canvas mainCanvas;
121                 mainCanvas.Construct(mainRect);
122                 mainCanvas.DrawBitmap(mainRect, bitmap);
123                 pResultBitmap = new (std::nothrow) Bitmap();
124                 result r = pResultBitmap->Construct(mainCanvas, mainRect);
125                 TryCatch(r == E_SUCCESS, , "pResultBitmap->Construct Failed:%s", GetErrorMessage(r));
126         }
127         return pResultBitmap;
128
129 CATCH:
130         delete pResultBitmap;
131         pResultBitmap = null;
132
133         return null;
134
135 }