2 // Open Service Platform
3 // Copyright (c) 2012 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 language governing permissions and
15 // limitations under the License.
19 * @file FMediaImage.cpp
20 * @brief This file contains the implementation of subsystem's Image.
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"
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Base;
34 using namespace Tizen::Io;
35 using namespace Tizen::App;
37 namespace Tizen { namespace Media
40 static const int MIN_LIMIT_SIZE = 1024;
49 if (__pImageImpl != null)
57 Image::Construct(void)
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 ");
67 r = pImageImpl->Construct();
68 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Create instance failed.", GetErrorMessage(r));
70 __pImageImpl = pImageImpl;
83 Image::DecodeN(const String& srcImagePath, BitmapPixelFormat pixelFormat) const
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 SysSecureTryCatch(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);
101 Image::DecodeN(const String& srcImagePath, BitmapPixelFormat pixelFormat, int destWidth, int destHeight) const
103 result r = E_SUCCESS;
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 SysSecureTryCatch(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);
114 return _ImageImpl::DecodeToBitmapN(srcImagePath, pixelFormat, Dimension(destWidth, destHeight));
121 Image::DecodeN(const ByteBuffer& srcImageBuf, ImageFormat srcImageFormat,
122 BitmapPixelFormat pixelFormat) const
124 result r = E_SUCCESS;
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);
133 return _ImageImpl::DecodeToBitmapN(srcImageBuf, pixelFormat);
141 Image::DecodeN(const ByteBuffer& srcImageBuf, ImageFormat imgFormat, BitmapPixelFormat pixelFormat,
142 int destWidth, int destHeight) const
144 result r = E_SUCCESS;
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);
155 return _ImageImpl::DecodeToBitmapN(srcImageBuf, pixelFormat, Dimension(destWidth, destHeight), BUFFER_SCALING_AUTO);
163 Image::DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat,
164 float destWidth, float destHeight) const
166 result r = E_SUCCESS;
168 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
169 SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
170 SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
171 "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
172 SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
173 r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
174 SysTryCatch(NID_MEDIA, destWidth > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destWidth:%d", destWidth);
175 SysTryCatch(NID_MEDIA, destHeight > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destHeight:%d", destHeight);
177 return _ImageImpl::DecodeToBitmapN(srcImagePath, pixelFormat, FloatDimension(destWidth, destHeight));
185 Image::DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat,
186 float destWidth, float destHeight) const
188 result r = E_SUCCESS;
190 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
191 SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
192 SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
193 r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
194 SysTryCatch(NID_MEDIA, destWidth > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destWidth:%d", destWidth);
195 SysTryCatch(NID_MEDIA, destHeight > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destHeight:%d", destHeight);
197 return _ImageImpl::DecodeToBitmapN(srcImageBuf, pixelFormat, FloatDimension(destWidth, destHeight));
204 Image::EncodeToBufferN(const Bitmap& srcImageBuf, ImageFormat destImageFormat) const
206 result r = E_SUCCESS;
208 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
209 SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
210 SysTryCatch(NID_MEDIA, ((destImageFormat==IMG_FORMAT_BMP) || (destImageFormat==IMG_FORMAT_JPG) || (destImageFormat==IMG_FORMAT_PNG)),
211 r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] destImageFormat:%d", destImageFormat);
212 SysTryCatch(NID_MEDIA, srcImageBuf.GetWidth() > 0 && srcImageBuf.GetHeight() > 0, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
213 "[E_OBJ_NOT_FOUND] bmp.width=%d,height=%d", srcImageBuf.GetWidth(), srcImageBuf.GetHeight());
216 return _ImageImpl::EncodeToBufferN(srcImageBuf, destImageFormat);
223 Image::EncodeToFile(const Bitmap& srcImageBuf, ImageFormat destImageFormat,
224 const String& destImagePath, bool overwrite) const
226 result r = E_SUCCESS;
228 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
229 SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
230 SysTryCatch(NID_MEDIA, ((destImageFormat==IMG_FORMAT_BMP) || (destImageFormat==IMG_FORMAT_JPG) || (destImageFormat==IMG_FORMAT_PNG)),
231 r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] destImageFormat:%d", destImageFormat);
232 SysTryCatch(NID_MEDIA, srcImageBuf.GetWidth() > 0 && srcImageBuf.GetHeight() > 0, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
233 "[E_OBJ_NOT_FOUND] bmp.width=%d,height=%d", srcImageBuf.GetWidth(), srcImageBuf.GetHeight());
235 return _ImageImpl::EncodeToFile(srcImageBuf, destImageFormat, destImagePath, overwrite);
242 Image::ConvertN(const String& srcImagePath, ImageFormat destImageFormat) const
244 result r = E_SUCCESS;
246 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
247 SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] path is empty");
248 SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
249 "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
250 SysTryCatch(NID_MEDIA, ((destImageFormat>IMG_FORMAT_NONE) && (destImageFormat<=IMG_FORMAT_WBMP)), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
251 "[E_UNSUPPORTED_FORMAT] destImageFormat:%d", destImageFormat);
253 return _ImageImpl::ConvertToBufferN(srcImagePath, destImageFormat);
261 Image::CompressJpeg(const Tizen::Base::String& srcImagePath, const Tizen::Base::String& destImagePath, int limitSize) const
263 result r = E_SUCCESS;
264 ImageFormat imgFormat;
266 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
267 SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
268 SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
269 "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
271 // CompressJpeg should accept only jpeg encoded images.
272 imgFormat = _ImageUtilImpl::GetImageFormat(srcImagePath);
273 SysTryCatch(NID_MEDIA, imgFormat == IMG_FORMAT_JPG, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
274 "[E_UNSUPPORTED_FORMAT] image format(%d) != JPG", imgFormat);
276 SysTryCatch(NID_MEDIA, limitSize > MIN_LIMIT_SIZE, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
277 "[E_OUT_OF_RANGE] limitSize:%d < %d", limitSize, MIN_LIMIT_SIZE);
279 return _ImageImpl::CompressJpeg(srcImagePath, destImagePath, limitSize);
285 Tizen::Base::ByteBuffer*
286 Image::CompressJpegN(const Tizen::Base::ByteBuffer& srcImageBuf, int limitSize) const
288 result r = E_SUCCESS;
289 ImageFormat imgFormat;
291 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
292 SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
294 SysTryCatch(NID_MEDIA, limitSize > MIN_LIMIT_SIZE, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
295 "[E_OUT_OF_RANGE] limitSize:%d < %d", limitSize, MIN_LIMIT_SIZE);
296 SysTryCatch(NID_MEDIA, srcImageBuf.GetCapacity() > limitSize, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
297 "[E_OUT_OF_RANGE] srcSize(%d) <= limitSize(%d)", srcImageBuf.GetCapacity(), limitSize);
299 imgFormat = _ImageUtilImpl::GetImageFormat(srcImageBuf);
300 SysTryCatch(NID_MEDIA, imgFormat == IMG_FORMAT_JPG, r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
301 "[E_UNSUPPORTED_FORMAT] image format(%d) != JPG", imgFormat);
303 return _ImageImpl::CompressJpegN(srcImageBuf, limitSize);
310 Tizen::Base::ByteBuffer*
311 Image::DecodeToBufferN(const Tizen::Base::ByteBuffer& srcImageBuf, ImageFormat srcImageFormat,
312 Tizen::Graphics::BitmapPixelFormat pixelFormat,
313 int& imageWidth, int& imageHeight) const
316 ByteBuffer* pBuf = null;
317 result r = E_SUCCESS;
319 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
320 SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
321 SysTryCatch(NID_MEDIA, ((srcImageFormat>IMG_FORMAT_NONE) && (srcImageFormat<=IMG_FORMAT_WBMP)), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
322 "[E_UNSUPPORTED_FORMAT] srcImageFormat:%d", srcImageFormat);
323 SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
324 r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
326 pBuf = _ImageImpl::DecodeToBufferN(srcImageBuf, dim, Dimension(0,0), pixelFormat, srcImageFormat);
327 SysTryCatch(NID_MEDIA, pBuf != null, r = GetLastResult(), GetLastResult(),
328 "[%s] Propagated.", GetErrorMessage(GetLastResult()));
329 imageWidth = dim.width;
330 imageHeight = dim.height;
339 Tizen::Base::ByteBuffer*
340 Image::DecodeToBufferN(const Tizen::Base::String& srcImagePath,
341 Tizen::Graphics::BitmapPixelFormat pixelFormat,
342 int& imageWidth, int& imageHeight) const
345 ByteBuffer* pBuf = null;
346 result r = E_SUCCESS;
348 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
349 SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
350 SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
351 "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
352 SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
353 r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
355 pBuf = _ImageImpl::DecodeToBufferN(srcImagePath, dim, Dimension(0,0), pixelFormat);
356 SysTryCatch(NID_MEDIA, pBuf != null, r = GetLastResult(), GetLastResult(),
357 "[%s] Propagated.", GetErrorMessage(GetLastResult()));
358 imageWidth = dim.width;
359 imageHeight = dim.height;
369 Image::GetImageFormat(const Tizen::Base::String& srcImagePath) const
372 result r = E_SUCCESS;
374 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
375 SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
376 SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
377 "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
378 fmt = _ImageUtilImpl::GetImageFormat(srcImagePath);
381 if (r == E_INVALID_DATA || r == E_INVALID_ARG)
383 SetLastResult(E_UNSUPPORTED_FORMAT);
389 return IMG_FORMAT_NONE;
394 Image::GetImageFormat(const Tizen::Base::ByteBuffer& srcImageBuf) const
397 result r = E_SUCCESS;
399 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
400 SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImagePath is null");
402 fmt = _ImageUtilImpl::GetImageFormat(srcImageBuf);
405 if (r == E_INVALID_DATA || r == E_INVALID_ARG)
407 SetLastResult(E_UNSUPPORTED_FORMAT);
413 return IMG_FORMAT_NONE;
417 Image::HasAlphaChannels(const Tizen::Base::String& srcImagePath) const
419 result r = E_SUCCESS;
421 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
422 SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
423 SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
424 "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
426 return _ImageUtilImpl::HasAlphaChannel(srcImagePath);
434 Image::HasAlphaChannels(const Tizen::Base::ByteBuffer& srcImageBuf) const
436 result r = E_SUCCESS;
438 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
439 SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
441 return _ImageUtilImpl::HasAlphaChannel(srcImageBuf);
448 Image::DecodeUrl(const Tizen::Base::Utility::Uri& srcImageUrl,
449 Tizen::Graphics::BitmapPixelFormat pixelFormat, int destWidth,
450 int destHeight, RequestId& reqId, const IImageDecodeUrlEventListener& listener,
453 result r = E_SUCCESS;
455 SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
456 SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
457 r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
458 SysTryCatch(NID_MEDIA, destWidth > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destWidth:%d", destWidth);
459 SysTryCatch(NID_MEDIA, destHeight > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destHeight:%d", destHeight);
461 SysTryCatch(NID_MEDIA, timeout == TIMEOUT_INFINITE || timeout > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE,
462 "[E_OUT_OF_RANGE] timeout:%d", timeout);
464 r = __pImageImpl->DecodeUrl(srcImageUrl, pixelFormat, destWidth,destHeight, reqId, listener, timeout);
465 SysTryCatch(NID_MEDIA, r == E_SUCCESS , , r, "[%s] Propagated.", GetErrorMessage(r));