result
QrCodeGenerator::EncodeToFile(const Tizen::Base::String& message, QrCodeMode mode, QrCodeErrorCorrectionLevel errorCorrectionLevel, bool compatibility, const Tizen::Base::String& imageFilePath, Tizen::Media::ImageFormat imageFormat, int& width, int& height)
{
+ result r = E_SUCCESS;
SysAssertf(__pQrCodeGeneratorImpl != null, "Not yet constructed! Consruct() should be called before use.");
SysSecureTryReturnResult(NID_UIX, !message.IsEmpty(), E_INVALID_ARG,
Tizen::Text::Utf8Encoding utf8;
std::unique_ptr<Tizen::Base::ByteBuffer> pBuffer(utf8.GetBytesN(message));
- if (!__pQrCodeGeneratorImpl->Encode((char*) pBuffer->GetPointer(), mode, errorCorrectionLevel, compatibility))
- {
- return E_FAILURE;
- }
+ if (!__pQrCodeGeneratorImpl->Encode((char*) pBuffer->GetPointer(), mode, errorCorrectionLevel, compatibility))
+ {
+ return E_OPERATION_FAILED;
+ }
+
+ if(!__pQrCodeGeneratorImpl->SaveToFile(imageFilePath, imageFormat,width, height))
+ {
+ r = GetLastResult();
+ if( r == E_ILLEGAL_ACCESS || r == E_OUT_OF_RANGE)
+ r = E_FILE_NOT_FOUND;
+ }
- return __pQrCodeGeneratorImpl->SaveToFile(imageFilePath, imageFormat, width, height) ? E_SUCCESS : E_FAILURE;
+ return r;
}
Tizen::Base::Collection::IListT<Tizen::Media::ImageFormat>*
{
if(!GetSize(width, height))
{
+ SetLastResult(E_INVALID_ARG);
return false;
}
unsigned char* grayBuffer = new unsigned char[(width * height * 3) >> 1];
if(!SaveToBuffer(grayBuffer))
{
+ SetLastResult(E_OPERATION_FAILED); //No proper error returned from SaveToBuffer() Api.
return false;
}
delete[] grayBuffer;
if(IsFailed(r))
{
- return false;
+ SetLastResult(r);
+ return false;
}
r = imBuf.EncodeToFile(imagepath, imageFormat, true);
if(IsFailed(r))
{
- return false;
+ SetLastResult(r);
+ return false;
}
return true;