Tizen 2.1 base
[platform/framework/native/image.git] / src / FMediaImage.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file   FMediaImage.cpp
20  * @brief  This file contains the implementation of subsystem's Image.
21  */
22
23 #include <FIoFile.h>
24 #include <FMediaImage.h>
25 #include <FMediaImageUtil.h>
26 #include <FBaseInternalTypes.h>
27 #include <FBaseSysLog.h>
28 #include <FApp_AppInfo.h>
29 #include "FMedia_ImageImpl.h"
30 #include "FMedia_ImageUtilImpl.h"
31
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Base;
34 using namespace Tizen::Io;
35 using namespace Tizen::App;
36
37 namespace Tizen { namespace Media
38 {
39
40 static const int MIN_LIMIT_SIZE = 1024;
41
42 Image::Image(void)
43 {
44         __pImageImpl = null;
45 }
46
47 Image::~Image(void)
48 {
49         if (__pImageImpl != null)
50         {
51                 delete __pImageImpl;
52                 __pImageImpl = null;
53         }
54 }
55
56 result
57 Image::Construct(void)
58 {
59         result r = E_SUCCESS;
60
61         SysAssertf(__pImageImpl == null,
62                 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
63         _ImageImpl* pImageImpl = new (std::nothrow) _ImageImpl();
64         SysTryCatch(NID_MEDIA, pImageImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
65                           "[E_OUT_OF_MEMORY] Construct Failed ");
66
67         r = pImageImpl->Construct();
68         SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Create instance failed.", GetErrorMessage(r));
69
70         __pImageImpl = pImageImpl;
71         return E_SUCCESS;
72
73 CATCH:
74         if (pImageImpl)
75         {
76                 delete pImageImpl;
77                 pImageImpl = null;
78         }
79         return r;
80 }
81
82 Bitmap*
83 Image::DecodeN(const String& srcImagePath, BitmapPixelFormat pixelFormat) const
84 {
85         result r = E_SUCCESS;
86
87         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
88         SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
89         SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
90                           "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
91         SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
92                           r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
93         return _ImageImpl::DecodeToBitmapN(srcImagePath, pixelFormat);
94
95 CATCH:
96         return null;
97 }
98
99
100 Bitmap*
101 Image::DecodeN(const String& srcImagePath, BitmapPixelFormat pixelFormat, int destWidth, int destHeight) const
102 {
103         result r = E_SUCCESS;
104
105         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
106         SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
107         SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
108                           "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
109         SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
110                           r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
111         SysTryCatch(NID_MEDIA, destWidth > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destWidth:%d", destWidth);
112         SysTryCatch(NID_MEDIA, destHeight > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destHeight:%d", destHeight);
113
114         return _ImageImpl::DecodeToBitmapN(srcImagePath, pixelFormat, Dimension(destWidth, destHeight));
115
116 CATCH:
117         return null;
118 }
119
120 Bitmap*
121 Image::DecodeN(const ByteBuffer& srcImageBuf, ImageFormat srcImageFormat,
122                            BitmapPixelFormat pixelFormat) const
123 {
124         result r = E_SUCCESS;
125
126         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
127         SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
128         SysTryCatch(NID_MEDIA, ((srcImageFormat>IMG_FORMAT_NONE) && (srcImageFormat<=IMG_FORMAT_WBMP)), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
129                           "[E_UNSUPPORTED_FORMAT] srcImageFormat:%d", srcImageFormat);
130         SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
131                           r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] %s=%d", "pixelFormat", pixelFormat);
132
133         return _ImageImpl::DecodeToBitmapN(srcImageBuf, pixelFormat);
134
135 CATCH:
136         return null;
137 }
138
139
140 Bitmap*
141 Image::DecodeN(const ByteBuffer& srcImageBuf, ImageFormat imgFormat, BitmapPixelFormat pixelFormat,
142                            int destWidth, int destHeight) const
143 {
144         result r = E_SUCCESS;
145
146         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
147         SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
148         SysTryCatch(NID_MEDIA, ((imgFormat>IMG_FORMAT_NONE) && (imgFormat<=IMG_FORMAT_WBMP)), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
149                           "[E_UNSUPPORTED_FORMAT] imgFormat:%d", imgFormat);
150         SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
151                           r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
152         SysTryCatch(NID_MEDIA, destWidth > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destWidth:%d", destWidth);
153         SysTryCatch(NID_MEDIA, destHeight > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destHeight:%d", destHeight);
154
155         return _ImageImpl::DecodeToBitmapN(srcImageBuf, pixelFormat, Dimension(destWidth, destHeight),
156                                                                            BUFFER_SCALING_AUTO, imgFormat);
157
158 CATCH:
159         return null;
160 }
161
162
163 ByteBuffer*
164 Image::EncodeToBufferN(const Bitmap& srcImageBuf, ImageFormat destImageFormat) const
165 {
166         result r = E_SUCCESS;
167
168         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
169         SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
170         SysTryCatch(NID_MEDIA, ((destImageFormat==IMG_FORMAT_BMP) || (destImageFormat==IMG_FORMAT_JPG) || (destImageFormat==IMG_FORMAT_PNG)),
171                           r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] destImageFormat:%d", destImageFormat);
172         SysTryCatch(NID_MEDIA, srcImageBuf.GetWidth() > 0 && srcImageBuf.GetHeight() > 0, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
173                           "[E_OBJ_NOT_FOUND] bmp.width=%d,height=%d", srcImageBuf.GetWidth(), srcImageBuf.GetHeight());
174
175
176         return _ImageImpl::EncodeToBufferN(srcImageBuf, destImageFormat);
177
178 CATCH:
179         return null;
180 }
181
182 result
183 Image::EncodeToFile(const Bitmap& srcImageBuf, ImageFormat destImageFormat,
184                                         const String& destImagePath, bool overwrite) const
185 {
186         result r = E_SUCCESS;
187
188         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
189         SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
190         SysTryCatch(NID_MEDIA, ((destImageFormat==IMG_FORMAT_BMP) || (destImageFormat==IMG_FORMAT_JPG) || (destImageFormat==IMG_FORMAT_PNG)),
191                           r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] destImageFormat:%d", destImageFormat);
192         SysTryCatch(NID_MEDIA, srcImageBuf.GetWidth() > 0 && srcImageBuf.GetHeight() > 0, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
193                           "[E_OBJ_NOT_FOUND] bmp.width=%d,height=%d", srcImageBuf.GetWidth(), srcImageBuf.GetHeight());
194
195         return _ImageImpl::EncodeToFile(srcImageBuf, destImageFormat, destImagePath, overwrite);
196
197 CATCH:
198         return r;
199 }
200
201 ByteBuffer*
202 Image::ConvertN(const String& srcImagePath, ImageFormat destImageFormat) const
203 {
204         result r = E_SUCCESS;
205
206         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
207         SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] path is empty");
208         SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
209                           "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
210         SysTryCatch(NID_MEDIA, ((destImageFormat>IMG_FORMAT_NONE) && (destImageFormat<=IMG_FORMAT_WBMP)), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
211                           "[E_UNSUPPORTED_FORMAT] destImageFormat:%d", destImageFormat);
212
213         return _ImageImpl::ConvertToBufferN(srcImagePath, destImageFormat);
214
215 CATCH:
216         return null;
217 }
218
219
220 result
221 Image::CompressJpeg(const Tizen::Base::String& srcImagePath, const Tizen::Base::String& destImagePath, int limitSize) const
222 {
223         result r = E_SUCCESS;
224         ImageFormat imgFormat;
225
226         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
227         SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
228         SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
229                           "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
230
231         // CompressJpeg should accept only jpeg encoded images.
232         imgFormat = _ImageUtilImpl::GetImageFormat(srcImagePath);
233         SysTryCatch(NID_MEDIA, imgFormat == IMG_FORMAT_JPG, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
234                           "[E_UNSUPPORTED_FORMAT] image format(%d) != JPG", imgFormat);
235
236         SysTryCatch(NID_MEDIA, limitSize > MIN_LIMIT_SIZE, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
237                           "[E_OUT_OF_RANGE] limitSize:%d < %d", limitSize, MIN_LIMIT_SIZE);
238
239         return _ImageImpl::CompressJpeg(srcImagePath, destImagePath, limitSize);
240
241 CATCH:
242         return r;
243 }
244
245 Tizen::Base::ByteBuffer*
246 Image::CompressJpegN(const Tizen::Base::ByteBuffer& srcImageBuf, int limitSize) const
247 {
248         result r = E_SUCCESS;
249         ImageFormat imgFormat;
250
251         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
252         SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
253
254         SysTryCatch(NID_MEDIA, limitSize > MIN_LIMIT_SIZE, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
255                           "[E_OUT_OF_RANGE] limitSize:%d < %d", limitSize, MIN_LIMIT_SIZE);
256         SysTryCatch(NID_MEDIA, srcImageBuf.GetCapacity() > limitSize, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
257                           "[E_OUT_OF_RANGE] srcSize(%d) <= limitSize(%d)", srcImageBuf.GetCapacity(), limitSize);
258
259         imgFormat = _ImageUtilImpl::GetImageFormat(srcImageBuf);
260         SysTryCatch(NID_MEDIA, imgFormat == IMG_FORMAT_JPG, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
261                           "[E_UNSUPPORTED_FORMAT] image format(%d) != JPG", imgFormat);
262
263         return _ImageImpl::CompressJpegN(srcImageBuf, limitSize);
264
265 CATCH:
266         return null;
267 }
268
269
270 Tizen::Base::ByteBuffer*
271 Image::DecodeToBufferN(const Tizen::Base::ByteBuffer& srcImageBuf, ImageFormat srcImageFormat,
272                                            Tizen::Graphics::BitmapPixelFormat pixelFormat,
273                                            int& imageWidth,  int& imageHeight) const
274 {
275         Dimension dim;
276         ByteBuffer* pBuf = null;
277         result r = E_SUCCESS;
278
279         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
280         SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
281         SysTryCatch(NID_MEDIA, ((srcImageFormat>IMG_FORMAT_NONE) && (srcImageFormat<=IMG_FORMAT_WBMP)), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
282                           "[E_UNSUPPORTED_FORMAT] srcImageFormat:%d", srcImageFormat);
283         SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
284                           r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
285
286         pBuf = _ImageImpl::DecodeToBufferN(srcImageBuf, dim, Dimension(0,0), pixelFormat, srcImageFormat);
287         SysTryCatch(NID_MEDIA, pBuf != null, r = GetLastResult(), GetLastResult(),
288                           "[%s] Propagated.", GetErrorMessage(GetLastResult()));
289         imageWidth = dim.width;
290         imageHeight = dim.height;
291
292         return pBuf;
293
294 CATCH:
295
296         return null;
297 }
298
299 Tizen::Base::ByteBuffer*
300 Image::DecodeToBufferN(const Tizen::Base::String& srcImagePath,
301                                            Tizen::Graphics::BitmapPixelFormat pixelFormat,
302                                            int& imageWidth, int& imageHeight) const
303 {
304         Dimension dim;
305         ByteBuffer* pBuf = null;
306         result r = E_SUCCESS;
307
308         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
309         SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
310         SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
311                           "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
312         SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
313                           r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
314
315         pBuf = _ImageImpl::DecodeToBufferN(srcImagePath, dim, Dimension(0,0), pixelFormat);
316         SysTryCatch(NID_MEDIA, pBuf != null, r = GetLastResult(), GetLastResult(),
317                           "[%s] Propagated.", GetErrorMessage(GetLastResult()));
318         imageWidth = dim.width;
319         imageHeight = dim.height;
320
321         return pBuf;
322
323 CATCH:
324
325         return null;
326 }
327
328 ImageFormat
329 Image::GetImageFormat(const Tizen::Base::String& srcImagePath) const
330 {
331         ImageFormat fmt;
332         result r = E_SUCCESS;
333
334         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
335         SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
336         SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
337                           "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
338         fmt = _ImageUtilImpl::GetImageFormat(srcImagePath);
339         r = GetLastResult();
340
341         if (r == E_INVALID_DATA || r == E_INVALID_ARG)
342         {
343                 SetLastResult(E_UNSUPPORTED_FORMAT);
344         }
345
346         return fmt;
347
348 CATCH:
349         return IMG_FORMAT_NONE;
350 }
351
352
353 ImageFormat
354 Image::GetImageFormat(const Tizen::Base::ByteBuffer& srcImageBuf) const
355 {
356         ImageFormat fmt;
357         result r = E_SUCCESS;
358
359         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
360         SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImagePath is null");
361
362         fmt = _ImageUtilImpl::GetImageFormat(srcImageBuf);
363         r = GetLastResult();
364
365         if (r == E_INVALID_DATA || r == E_INVALID_ARG)
366         {
367                 SetLastResult(E_UNSUPPORTED_FORMAT);
368         }
369
370         return fmt;
371
372 CATCH:
373         return IMG_FORMAT_NONE;
374 }
375
376 bool
377 Image::HasAlphaChannels(const Tizen::Base::String& srcImagePath) const
378 {
379         result r = E_SUCCESS;
380
381         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
382         SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
383         SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
384                           "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
385
386         return _ImageUtilImpl::HasAlphaChannel(srcImagePath);
387
388 CATCH:
389         return false;
390 }
391
392
393 bool
394 Image::HasAlphaChannels(const Tizen::Base::ByteBuffer& srcImageBuf) const
395 {
396         result r = E_SUCCESS;
397
398         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
399         SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
400
401         return _ImageUtilImpl::HasAlphaChannel(srcImageBuf);
402
403 CATCH:
404         return false;
405 }
406
407 result
408 Image::DecodeUrl(const Tizen::Base::Utility::Uri& srcImageUrl,
409                                  Tizen::Graphics::BitmapPixelFormat pixelFormat, int destWidth,
410                                  int destHeight, RequestId& reqId, const IImageDecodeUrlEventListener& listener,
411                                  long timeout) const
412 {
413         result r = E_SUCCESS;
414
415         SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
416         SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
417                           r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
418         SysTryCatch(NID_MEDIA, destWidth > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destWidth:%d", destWidth);
419         SysTryCatch(NID_MEDIA, destHeight > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destHeight:%d", destHeight);
420
421         SysTryCatch(NID_MEDIA, timeout == TIMEOUT_INFINITE || timeout > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
422                           "[E_OUT_OF_RANGE] timeout:%d", timeout);
423
424         r = __pImageImpl->DecodeUrl(srcImageUrl, pixelFormat, destWidth,destHeight, reqId, listener, timeout);
425 SysTryCatch(NID_MEDIA, r == E_SUCCESS , , r, "[%s] Propagated.", GetErrorMessage(r));
426
427         return r;
428
429 CATCH:
430         return r;
431 }
432
433 }} // Tizen::Media