2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 #include <FBaseSysLog.h>
18 #include "FUiCtrl_GalleryItem.h"
19 #include "FUiCtrl_GalleryBitmap.h"
21 using namespace Tizen::Base;
22 using namespace Tizen::Graphics;
24 namespace Tizen { namespace Ui { namespace Controls {
26 _GalleryItem::_GalleryItem(_GalleryBitmap* pImage, String imageFilePath, _GalleryImageRotation rotation)
27 : __pOriginImage(pImage)
29 , __imageFilePath(imageFilePath)
30 , __rotation(rotation)
36 _GalleryItem::~_GalleryItem(void)
39 delete __pOriginImage;
40 __pOriginImage = null;
47 _GalleryItem::SetGalleryItemImage(_GalleryBitmap* pImage)
54 _GalleryItem::GetGalleryItemImage(void) const
56 if (__pOriginImage == null)
58 SetLastResult(E_SYSTEM);
62 Dimension dim = __pOriginImage->GetSize();
63 Rectangle rect(0, 0, dim.width, dim.height);
66 _GalleryBitmap* pImage = null;
68 Bitmap* pBitmap = new(std::nothrow) Bitmap();
69 SysTryCatch(NID_UI_CTRL, pBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
71 r = pBitmap->Construct(*__pOriginImage->GetInternalBitmap(), rect);
72 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
74 pImage = _GalleryBitmap::CreateGalleryBitmapN(pBitmap);
75 SysTryCatch(NID_UI_CTRL, pImage != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
76 pImage->SetBitmapRotation(__pOriginImage->GetBitmapRotation());
77 const_cast<_GalleryItem*>(this)->SetGalleryItemImage(pImage);
84 const_cast<_GalleryItem*>(this)->SetGalleryItemImage(null);
89 _GalleryItem::SetOriginGalleryItemImage(_GalleryBitmap* pImage)
91 delete __pOriginImage;
92 __pOriginImage = pImage;
96 _GalleryItem::GetOriginItemImage(void) const
98 return __pOriginImage;
102 _GalleryItem::SetGalleryItemFilePath(String& filePath)
104 __imageFilePath = filePath;
108 _GalleryItem::GetGalleryItemFilePath(void) const
110 return __imageFilePath;
114 _GalleryItem::SetGalleryRotation(_GalleryImageRotation rotation)
116 __rotation = rotation;
119 _GalleryImageRotation
120 _GalleryItem::GetGalleryRotation(void) const
126 _GalleryItem::SetItemIndex(int groupIndex, int itemIndex)
128 __itemIndex = itemIndex;
132 _GalleryItem::GetItemIndex(int& groupIndex, int& itemIndex) const
135 itemIndex = __itemIndex;
138 }}} // Tizen::Ui::Controls