_ImageFeatureManagerImpl::_ImageFeatureManagerImpl(void)
: __imageFeatureManager(0)
, __readOnly(false)
+ , __minSupportedSize(100)
+ , __maxSupportedResolution(16000000)
{
}
int
_ImageFeatureManagerImpl::AddFeature(const Tizen::Base::String& filepath)
{
- Tizen::Media::ImageBuffer imBuf;
- result r = imBuf.Construct(filepath, null, false);
+ Tizen::Media::ImageFormat imgFormat;
+ int imgWidth = 0, imgHeight = 0;
+ result r = Tizen::Media::ImageBuffer::GetImageInfo(filepath, imgFormat, imgWidth, imgHeight);
+
if (IsFailed(r))
{
+ SetLastResult(E_INVALID_ARG);
+ return -1;
+ }
+
+ if ((imgWidth < __minSupportedSize || imgHeight < __minSupportedSize) || (imgWidth * imgHeight > __maxSupportedResolution))
+ {
+ SetLastResult(E_INVALID_ARG);
+ return -1;
+ }
+
+ Tizen::Media::ImageBuffer imBuf;
+ r = imBuf.Construct(filepath, null, false);
+
+ if(IsFailed(r))
+ {
+ SetLastResult(E_INVALID_ARG);
return -1;
}
{
return -1;
}
+
+ if ((width < __minSupportedSize || height < __minSupportedSize) || (width * height > __maxSupportedResolution))
+ {
+ SetLastResult(E_INVALID_ARG);
+ return -1;
+ }
+
Tizen::Text::Utf8Encoding utf8;
- int index = (int) __imageFeatureManager->addImageToDB(data, width, height, (char*) utf8.GetBytesN(info)->GetPointer());
+ std::unique_ptr<Tizen::Base::ByteBuffer> pBuffer(utf8.GetBytesN(info));
+ int index = (int) __imageFeatureManager->addImageToDB(data, width, height, (char*) pBuffer->GetPointer());
if (index > -1)
{
{
SetLastResult(E_INVALID_ARG);
}
-
+
return false;
}
SysSecureTryReturnResult(NID_UIX, !dbPath->IsEmpty(), E_INVALID_ARG,
"database path must not be empty. [E_INVALID_ARG]");
Tizen::Text::Utf8Encoding utf8;
- result = __imageFeatureManager->saveDB(optimizeDatabase, (const char*) utf8.GetBytesN(*dbPath)->GetPointer()) ? E_SUCCESS : E_FAILURE;
+ std::unique_ptr<Tizen::Base::ByteBuffer> pBuffer(utf8.GetBytesN(*dbPath));
+ result = __imageFeatureManager->saveDB(optimizeDatabase, (const char*) pBuffer->GetPointer()) ? E_SUCCESS : E_FAILURE;
}
else
{
if (!__path.IsEmpty())
{
Tizen::Text::Utf8Encoding utf8;
- result = __imageFeatureManager->saveDB(optimizeDatabase, (const char*) utf8.GetBytesN(__path)->GetPointer()) ? E_SUCCESS : E_FAILURE;
+ std::unique_ptr<Tizen::Base::ByteBuffer> pBuffer(utf8.GetBytesN(__path));
+ result = __imageFeatureManager->saveDB(optimizeDatabase, (const char*) pBuffer->GetPointer()) ? E_SUCCESS : E_FAILURE;
if (E_FAILURE == result && __readOnly)
{
result = E_INVALID_ARG;
__imageFeatureManager->initDB();
Tizen::Text::Utf8Encoding utf8;
- switch (__imageFeatureManager->openDB((const char*) utf8.GetBytesN(dbpath)->GetPointer()))
+ std::unique_ptr<Tizen::Base::ByteBuffer> pBuffer(utf8.GetBytesN(dbpath));
+ switch (__imageFeatureManager->openDB((const char*) pBuffer->GetPointer()))
{
case 0: //ok
__path = dbpath;