Applied latest source code
[apps/native/preloaded/MusicPlayer.git] / src / MpThumbnailInfo.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                MpThumbnailInfo.cpp
19  * @brief               This is the implementation file for ThumbnailInfo class.
20  */
21
22 #include <FGraphics.h>
23 #include "MpThumbnailInfo.h"
24
25 using namespace Tizen::Base;
26 using namespace Tizen::Content;
27 using namespace Tizen::Graphics;
28
29 ThumbnailInfo::ThumbnailInfo(void)
30         : __pBitmap(null)
31         , __pParam(null)
32 {
33         AppLogDebug("ENTER");
34         AppLogDebug("EXIT");
35 }
36
37 ThumbnailInfo::~ThumbnailInfo(void)
38 {
39         AppLogDebug("ENTER");
40         delete __pBitmap;
41         __pBitmap = null;
42         delete __pParam;
43         __pParam = null;
44         AppLogDebug("EXIT");
45 }
46
47 void
48 ThumbnailInfo::Construct(const Tizen::Content::ContentId& contentId,
49                                                 const Tizen::Graphics::Bitmap& bitmap, Tizen::Base::Object* pParam)
50 {
51         AppLogDebug("ENTER");
52         __contentId = contentId;
53         __pBitmap = &bitmap;
54         __pParam = pParam;
55         AppLogDebug("EXIT");
56 }
57
58 ContentId
59 ThumbnailInfo::GetContentId(void) const
60 {
61         AppLogDebug("ENTER");
62         AppLogDebug("EXIT");
63         return __contentId;
64 }
65
66 Bitmap*
67 ThumbnailInfo::GetBitmapN(void) const
68 {
69         AppLogDebug("ENTER");
70         AppLogDebug("EXIT");
71         return CloneBitmapN(*__pBitmap);
72 }
73
74 Tizen::Base::Object*
75 ThumbnailInfo::GetUserParamN(void) const
76 {
77         AppLogDebug("ENTER");
78         Object* pUserParam = __pParam;
79         __pParam = null;
80         AppLogDebug("EXIT");
81         return pUserParam;
82 }
83
84 Bitmap*
85 ThumbnailInfo::CloneBitmapN(const Bitmap& bitmap) const
86 {
87         AppLogDebug("ENTER");
88         Bitmap* pResultBitmap = null;
89         if (&bitmap != null)
90         {
91                 Rectangle mainRect(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
92                 Canvas mainCanvas;
93                 mainCanvas.Construct(mainRect);
94                 mainCanvas.DrawBitmap(mainRect, bitmap);
95                 pResultBitmap = new (std::nothrow) Bitmap();
96                 pResultBitmap->Construct(mainCanvas, mainRect);
97         }
98         AppLogDebug("EXIT");
99         return pResultBitmap;
100 }