Applied secure log for privacy protect
[platform/framework/native/image.git] / src / FMediaImage.cpp
index 2731462..75f01d5 100644 (file)
@@ -86,7 +86,7 @@ Image::DecodeN(const String& srcImagePath, BitmapPixelFormat pixelFormat) const
 
        SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
        SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
-       SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+       SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
                          "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
        SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
                          r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
@@ -104,7 +104,7 @@ Image::DecodeN(const String& srcImagePath, BitmapPixelFormat pixelFormat, int de
 
        SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
        SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
-       SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+       SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
                          "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
        SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
                          r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
@@ -152,14 +152,54 @@ Image::DecodeN(const ByteBuffer& srcImageBuf, ImageFormat imgFormat, BitmapPixel
        SysTryCatch(NID_MEDIA, destWidth > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destWidth:%d", destWidth);
        SysTryCatch(NID_MEDIA, destHeight > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destHeight:%d", destHeight);
 
-       return _ImageImpl::DecodeToBitmapN(srcImageBuf, pixelFormat, Dimension(destWidth, destHeight),
-                                                                          BUFFER_SCALING_AUTO, imgFormat);
+       return _ImageImpl::DecodeToBitmapN(srcImageBuf, pixelFormat, Dimension(destWidth, destHeight), BUFFER_SCALING_AUTO);
 
 CATCH:
        return null;
 }
 
 
+Bitmap*
+Image::DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat,
+                          float destWidth, float destHeight) const
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
+       SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
+       SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+                         "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
+       SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
+                         r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
+       SysTryCatch(NID_MEDIA, destWidth > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destWidth:%d", destWidth);
+       SysTryCatch(NID_MEDIA, destHeight > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destHeight:%d", destHeight);
+
+       return _ImageImpl::DecodeToBitmapN(srcImagePath, pixelFormat, FloatDimension(destWidth, destHeight));
+
+CATCH:
+       return null;
+}
+
+
+Bitmap*
+Image::DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat,
+                          float destWidth, float destHeight) const
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
+       SysTryCatch(NID_MEDIA, &srcImageBuf != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] srcImageBuf is null");
+       SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
+                         r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
+       SysTryCatch(NID_MEDIA, destWidth > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destWidth:%d", destWidth);
+       SysTryCatch(NID_MEDIA, destHeight > 0, r = E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] destHeight:%d", destHeight);
+
+       return _ImageImpl::DecodeToBitmapN(srcImageBuf, pixelFormat, FloatDimension(destWidth, destHeight));
+
+CATCH:
+       return null;
+}
+
 ByteBuffer*
 Image::EncodeToBufferN(const Bitmap& srcImageBuf, ImageFormat destImageFormat) const
 {
@@ -205,7 +245,7 @@ Image::ConvertN(const String& srcImagePath, ImageFormat destImageFormat) const
 
        SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
        SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] path is empty");
-       SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+       SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
                          "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
        SysTryCatch(NID_MEDIA, ((destImageFormat>IMG_FORMAT_NONE) && (destImageFormat<=IMG_FORMAT_WBMP)), r = E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT,
                          "[E_UNSUPPORTED_FORMAT] destImageFormat:%d", destImageFormat);
@@ -225,7 +265,7 @@ Image::CompressJpeg(const Tizen::Base::String& srcImagePath, const Tizen::Base::
 
        SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
        SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
-       SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+       SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
                          "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
 
        // CompressJpeg should accept only jpeg encoded images.
@@ -307,7 +347,7 @@ Image::DecodeToBufferN(const Tizen::Base::String& srcImagePath,
 
        SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
        SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
-       SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+       SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
                          "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
        SysTryCatch(NID_MEDIA, ((pixelFormat==BITMAP_PIXEL_FORMAT_RGB565) || (pixelFormat==BITMAP_PIXEL_FORMAT_ARGB8888) || (pixelFormat==BITMAP_PIXEL_FORMAT_R8G8B8A8)),
                          r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
@@ -333,7 +373,7 @@ Image::GetImageFormat(const Tizen::Base::String& srcImagePath) const
 
        SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
        SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
-       SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+       SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
                          "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
        fmt = _ImageUtilImpl::GetImageFormat(srcImagePath);
        r = GetLastResult();
@@ -380,7 +420,7 @@ Image::HasAlphaChannels(const Tizen::Base::String& srcImagePath) const
 
        SysAssertf(__pImageImpl != null, "Not yet constructed. Construct() should be called before use.");
        SysTryCatch(NID_MEDIA, !srcImagePath.IsEmpty(), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] srcImagePath is empty");
-       SysTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
+       SysSecureTryCatch(NID_MEDIA, File::IsFileExist(srcImagePath), r = E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
                          "[E_FILE_NOT_FOUND] srcImagePath:%ls", srcImagePath.GetPointer());
 
        return _ImageUtilImpl::HasAlphaChannel(srcImagePath);