2 // Open Service Platform
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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 languae governing permissions and
15 // limitations under the License.
18 #include <FUixVisionImageFeatureInfo.h>
19 #include "FUixVision_ImageFeatureInfoImpl.h"
21 #include <FBaseSysLog.h>
23 namespace Tizen { namespace Uix { namespace Vision
26 ImageFeatureInfo::ImageFeatureInfo()
27 : __pImageFeatureInfoImpl(0)
29 std::unique_ptr<_ImageFeatureInfoImpl> pImageFeatureInfoImpl (new (std::nothrow) _ImageFeatureInfoImpl());
30 __pImageFeatureInfoImpl = pImageFeatureInfoImpl.release();
33 ImageFeatureInfo::~ImageFeatureInfo()
35 if (__pImageFeatureInfoImpl != null)
37 delete __pImageFeatureInfoImpl;
38 __pImageFeatureInfoImpl = null;
43 ImageFeatureInfo::GetDescription() const
50 //get true length of path to allocate memory
51 length = __pImageFeatureInfoImpl->GetDescription(&ch, 1);
54 return Tizen::Base::String("");
57 std::unique_ptr<char[]> pName(new (std::nothrow) char[length + 1]);
58 SysSecureTryReturn(NID_UIX, pName != null, Tizen::Base::String(""), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY))
60 //set data to char pointer, with allocated memory
61 __pImageFeatureInfoImpl->GetDescription(pName.get(), length + 1);
63 Tizen::Base::String description(pName.get());
68 ImageFeatureInfo::GetThumbnailWidth(void) const
70 return __pImageFeatureInfoImpl->GetThumbnailWidth();
74 ImageFeatureInfo::GetThumbnailHeight(void) const
76 return __pImageFeatureInfoImpl->GetThumbnailHeight();
79 Tizen::Base::ByteBuffer*
80 ImageFeatureInfo::GetThumbnailN(void) const
82 int bufWidth = __pImageFeatureInfoImpl->GetThumbnailWidth();
83 SysSecureTryReturn(NID_UIX, bufWidth > 0, null, E_FAILURE, "[%s] Failed to get thumbnail width.", GetErrorMessage(E_FAILURE));
85 int bufHeight = __pImageFeatureInfoImpl->GetThumbnailHeight();
86 SysSecureTryReturn(NID_UIX, bufHeight > 0, null, E_FAILURE, "[%s] Failed to get thumbnail height.", GetErrorMessage(E_FAILURE));
88 std::unique_ptr<Tizen::Base::ByteBuffer> pOutBuffer(new (std::nothrow) Tizen::Base::ByteBuffer());
89 SysSecureTryReturn(NID_UIX, pOutBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
91 result res = pOutBuffer->Construct(bufWidth * bufHeight);
92 SysSecureTryReturn(NID_UIX, res == E_SUCCESS, null, res, "[%s] Failed to construct ByteBuffer.", GetErrorMessage(res));
94 bool success = __pImageFeatureInfoImpl->GetThumbnail((char*)pOutBuffer->GetPointer(), bufWidth, bufHeight, false);
95 SysSecureTryReturn(NID_UIX, success == true, null, E_FAILURE, "[%s] Failed to get thumbnail.", GetErrorMessage(E_FAILURE));
97 return pOutBuffer.release();
101 ImageFeatureInfo::Equals(const Object& obj) const
103 return (static_cast<const Object*>(this) == &obj);
107 ImageFeatureInfo::GetHashCode(void) const
109 return (int)__pImageFeatureInfoImpl;
112 } } } //Tizen::Uix::Vision