merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:16:48 +0000 (01:16 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:16:48 +0000 (01:16 +0900)
15 files changed:
CMakeLists.txt
inc/FMediaIImageEventListener.h [changed mode: 0644->0755]
inc/FMediaImage.h
inc/FMediaImageBuffer.h
inc/FMediaTypes.h [changed mode: 0644->0755]
packaging/osp-image.spec
src/FMediaImage.cpp
src/FMediaImageBuffer.cpp
src/FMedia_ExifUtil.cpp [deleted file]
src/FMedia_ImageBufferImpl.cpp
src/FMedia_ImageImpl.cpp
src/FMedia_ImageUriDataEvent.cpp
src/inc/FMedia_ExifUtil.h [deleted file]
src/inc/FMedia_ImageBufferImpl.h
src/inc/FMedia_ImageImpl.h

index 336ab4e..7f1400f 100755 (executable)
@@ -12,7 +12,7 @@ INCLUDE_DIRECTORIES(
        /usr/include/curl
        /usr/include/libxml2
        /usr/include/glib-2.0 
-  /usr/lib/glib-2.0/include
+       /usr/lib/glib-2.0/include
        /usr/include/osp
        /usr/include/osp/app
        /usr/include/osp/base   
@@ -40,7 +40,6 @@ SET (${this_target}_SOURCE_FILES
        src/FMedia_ImageUriDataEventArg.cpp
        src/FMedia_ImageUriDataFactory.cpp
        src/FMedia_ImageUriDataHolder.cpp
-       src/FMedia_ExifUtil.cpp
 )
 
 ## Definitions
@@ -63,7 +62,6 @@ TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" )
 TARGET_LINK_LIBRARIES(${this_target} "-losp-image-core" )
 TARGET_LINK_LIBRARIES(${this_target} "-losp-uifw" )
 TARGET_LINK_LIBRARIES(${this_target} "-losp-net" )
-TARGET_LINK_LIBRARIES(${this_target} "-lexif" )
 TARGET_LINK_LIBRARIES(${this_target} "-lpthread" )
 
 SET_TARGET_PROPERTIES(${this_target} 
old mode 100644 (file)
new mode 100755 (executable)
index 089b400..41d7750
@@ -50,7 +50,7 @@ class _OSP_EXPORT_ IImageDecodeUrlEventListener
 
 public:
        /**
-       * This is the destructor for this class.
+       * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
        *
        * @since                2.0
        */
index 1d2806d..1ee4f54 100644 (file)
@@ -256,6 +256,58 @@ public:
        Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, int destWidth, int destHeight) const;
 
        /**
+       * Decodes an image data into the decoded bitmap container after resizing it as per the specified width and height. @n
+       * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
+       * The %DecodeN() method retains the aspect ratio of the original image.
+       *
+       * @since                2.1
+       *
+       * @return               A decoded bitmap data with the specified destination width and height.
+       * @param[in]    srcImageBuf                             The data to decode
+       * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
+       * @param[in]    destWidth                               The intended width of the image.
+       * @param[in]    destHeight                              The intended height of the image.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
+       * @exception    E_INVALID_ARG                   The specified pixel format is not supported.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
+       * @exception    E_OBJ_NOT_FOUND                 The specified image buffer cannot be found.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @remarks              This method retains the aspect ratio of the original image.
+       * @remarks              It’s a high probability that the out-of-memory exception occurs. Check the exception as possible if it is E_OUT_OF_MEMORY.
+       *                               Refer to <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">Exception Check</a> and handle the out-of-memory.
+       * @remarks              This method returns auto scaled bitmap to support logical coordinate system, so the actual dimension of the returned bitmap can be vary depending on the physical dimension of target device.
+       */
+       Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat, float destWidth, float destHeight) const;
+
+       /**
+       * Decodes an image file into the decoded bitmap container after resizing it as per the specified width and height. @n
+       * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP. @n
+       * The %DecodeN() method retains the aspect ratio of the original image.
+       *
+       * @since                2.1
+       *
+       * @return               A decoded bitmap data with the specified destination width and height.
+       * @param[in]    srcImagePath                    The local file path of the image file to open
+       * @param[in]    pixelFormat                             The output pixel format defined by Tizen::Graphics::BitmapPixelFormat
+       * @param[in]    destWidth                               The intended width of the image.
+       * @param[in]    destHeight                              The intended height of the image.
+       * @exception    E_SUCCESS                               The method is successful.
+       * @exception    E_INVALID_ARG                   The specified pixel format is not supported.
+       * @exception    E_INVALID_DATA                  The specified input instance has invalid data.
+       * @exception    E_UNSUPPORTED_FORMAT    The specified format is not supported.
+       * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
+       * @exception    E_FILE_NOT_FOUND                The specified file cannot be found or accessed.
+       * @remarks              The specific error code can be accessed using the GetLastResult() method.
+       * @remarks              This method retains the aspect ratio of the original image.
+       * @remarks              It’s a high probability that the out-of-memory exception occurs. Check the exception as possible if it is E_OUT_OF_MEMORY.
+       *                               Refer to <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">Exception Check</a> and handle the out-of-memory.
+       * @remarks              This method returns auto scaled bitmap to support logical coordinate system, so the actual dimension of the returned bitmap can be vary depending on the physical dimension of target device.
+       */
+       Tizen::Graphics::Bitmap* DecodeN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, float destWidth, float destHeight) const;
+
+       /**
        * Decodes an image data into the decoded bitmap as per the specified width and height. @n
        * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
        *
index 055c598..64c3739 100644 (file)
@@ -26,7 +26,6 @@
 #define _FMEDIA_IMAGEBUFFER_H_
 
 #include <FMediaImage.h>
-#include <FMediaTypes.h>
 
 namespace Tizen { namespace Media
 {
@@ -174,6 +173,62 @@ public:
        result Construct(const Tizen::Graphics::Bitmap &srcBitmap);
 
        /**
+       * Initializes this instance of %ImageBuffer with the decoded data of the given image path with the specified parameters.
+       *
+       * @since 2.1
+       *
+       * @return     An error code
+       * @param[in]  srcImagePath          The source image path
+       * @param[in]  destWidth             The intended width of the image.
+       * @param[in]  destHeight            The intended height of the image.
+       * @param[in]  scalingMethod         The scaling method.
+       * @exception  E_SUCCESS             The method is successful.
+       * @exception  E_INVALID_ARG         A specified input parameter is invalid.
+       * @exception  E_UNSUPPORTED_FORMAT  The specified format is not supported.
+       * @exception  E_OUT_OF_MEMORY       The memory is insufficient.
+       * @exception  E_FILE_NOT_FOUND      The specified file cannot be found or accessed.
+       * @remarks    There is a high probability for an occurrence of an out-of-memory exception.
+       *             If possible, check whether the exception is E_OUT_OF_MEMORY or not. @n
+       *             For more information on how to handle the out-of-memory exception, refer to
+       *             <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.html>Exception Check</a>
+       * @remarks    This method does not retain the aspect ratio of the original image.
+       */
+       result Construct(const Tizen::Base::String &srcImagePath, int destWidth, int destHeight, ImageScalingMethod scalingMethod);
+
+       /**
+       * Initializes this instance of %ImageBuffer with the decoded data of the given image buffer with the specified parameters.
+       *
+       * @since 2.1
+       *
+       * @return     An error code
+       * @param[in]  srcImageBuf           The buffer that contains compressed image data
+       * @param[in]  destWidth             The intended width of the image.
+       * @param[in]  destHeight            The intended height of the image.
+       * @param[in]  scalingMethod         The scaling method.
+       * @exception  E_SUCCESS             The method is successful.
+       * @exception  E_INVALID_ARG         A specified input parameter is invalid.
+       * @exception  E_UNSUPPORTED_FORMAT  The specified format is not supported.
+       * @exception  E_OUT_OF_MEMORY       The memory is insufficient.
+       * @remarks    There is a high probability for an occurrence of an out-of-memory exception.
+       *             If possible, check whether the exception is E_OUT_OF_MEMORY or not. @n
+       *             For more information on how to handle the out-of-memory exception, refer to
+       *             <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.html>Exception Check</a>
+       * @remarks    This method does not retain the aspect ratio of the original image.
+       */
+       result Construct(const Tizen::Base::ByteBuffer &srcImageBuf, int destWidth, int destHeight, ImageScalingMethod scalingMethod);
+
+       /**
+       * Gets the current exif orientation of image data. @n
+       * If automatic rotation is enabled during Construct() then the orientation will be reset to default value.
+       *
+       * @since 2.1
+       *
+       * @return Orientation information of the current image data.
+       */
+       ExifOrientation GetExifOrientation(void) const;
+
+
+       /**
        * Converts an instance of the Tizen::Base::Object class to an instance of %ImageBuffer and then
        * compares it with the calling %ImageBuffer instance.
        *
@@ -281,6 +336,25 @@ public:
        Tizen::Graphics::Bitmap* GetBitmapN(Tizen::Graphics::BitmapPixelFormat pixelFormat, Tizen::Graphics::BufferScaling bufferScaling) const;
 
        /**
+       * Gets an instance of Tizen::Graphics::Bitmap with the data of this instance after resizing it as per the specified width and height
+       *
+       * @since 2.1
+       *
+       * @return     A pointer to the Tizen::Graphics::Bitmap instance with the specified destination width and height.
+       * @param[in]  pixelFormat           The bitmap pixel format
+       * @param[in]  destWidth             The intended width of the image.
+       * @param[in]  destHeight            The intended height of the image.
+       * @exception  E_SUCCESS             The method is successful.
+       * @exception  E_INVALID_ARG         A specified input parameter is invalid.
+       * @exception  E_UNSUPPORTED_FORMAT  The specified format is not supported.
+       * @exception  E_OUT_OF_MEMORY       The memory is insufficient.
+       * @remarks    The specific error code can be accessed using the GetLastResult() method.
+       * @remarks    This method returns auto scaled bitmap to support logical coordinate system,
+       *             so the actual dimension of the returned bitmap can be vary depending on the physical dimension of target device.
+       */
+       Tizen::Graphics::Bitmap* GetBitmapN(Tizen::Graphics::BitmapPixelFormat pixelFormat, float destWidth, float destHeight) const;
+
+       /**
        * Gets an instance of Tizen::Base::ByteBuffer with the data of this instance.
        *
        * @since 2.0
old mode 100644 (file)
new mode 100755 (executable)
index 39d13f0..abdee60
@@ -188,6 +188,22 @@ enum H263ProfileType
        H263_PROFILE_VERSION_2 = 0x03,          /**< The version 2 interactive and streaming wireless profile */
 };
 
+/**
+ *  @enum VideoPlaneType
+ *
+ *  Defines the types of the video plane
+ *
+ *  @since     2.1
+ */
+enum VideoPlaneType
+{
+       VIDEO_PLANE_TYPE_NONE = 0,              /**< No video plane */
+       VIDEO_PLANE_TYPE_Y,                             /**< The Y video plane */
+       VIDEO_PLANE_TYPE_U,                             /**< The U video plane */
+       VIDEO_PLANE_TYPE_V,                             /**< The V video plane */
+       VIDEO_PLANE_TYPE_UV,                    /**< The UV video plane */
+       VIDEO_PLANE_TYPE_YUV,                   /**< The YUV video plane */
+};
 
 };
 };   // Tizen::Media
index 83fb7fc..f34b3b2 100755 (executable)
@@ -3,7 +3,7 @@
 
 Name:       osp-image
 Summary:    The Media Image library of OSP 
-Version:    1.2.0.0
+Version:    1.2.1.0
 Release:    1
 Group:      TO_BE/FILLED_IN
 License:    TO BE FILLED IN
@@ -18,7 +18,6 @@ BuildRequires:  pkgconfig(osp-uifw)
 BuildRequires:  osp-uifw-internal-devel
 BuildRequires:  pkgconfig(osp-net)
 BuildRequires:  osp-net-internal-devel
-BuildRequires:  libexif-devel
 BuildRequires:  pkgconfig(openssl)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(libavcodec)
index 2731462..b391fd6 100644 (file)
@@ -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");
+       SysTryCatch(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
 {
index 41e2ad1..697ad1e 100644 (file)
@@ -174,6 +174,82 @@ CATCH:
        return r;
 }
 
+
+
+
+
+result
+ImageBuffer::Construct(const Tizen::Base::String &srcImagePath,
+       int destWidth, int destHeight, ImageScalingMethod scalingMethod)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl == null,
+               "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       SysTryReturnResult(NID_MEDIA, !srcImagePath.IsEmpty(), E_INVALID_ARG,"path is empty.");
+
+       SysTryReturnResult(NID_MEDIA, File::IsFileExist(srcImagePath), E_FILE_NOT_FOUND,
+               "file not found: %ls", srcImagePath.GetPointer());
+
+       _ImageBufferImpl* pImageBufferImpl = new (std::nothrow) _ImageBufferImpl();
+       SysTryReturnResult(NID_MEDIA, pImageBufferImpl != null, E_OUT_OF_MEMORY, "Create instance failed.");
+
+       r = pImageBufferImpl->Construct(srcImagePath, destWidth, destHeight, scalingMethod);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , GetLastResult(),
+                       "[%s] Construct instance failed.", GetErrorMessage(GetLastResult()));
+
+       __pImpl = pImageBufferImpl;
+       return r;
+
+CATCH:
+       if (pImageBufferImpl != null)
+       {
+               delete pImageBufferImpl;
+               pImageBufferImpl = null;
+       }
+       return r;
+}
+
+result
+ImageBuffer::Construct(const Tizen::Base::ByteBuffer &srcImageBuf,
+       int destWidth, int destHeight, ImageScalingMethod scalingMethod)
+{
+       result r = E_SUCCESS;
+
+       SysAssertf(__pImpl == null,
+               "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+       SysTryReturnResult(NID_MEDIA, &srcImageBuf != null, E_INVALID_ARG,
+               "src buffer is null");
+
+       _ImageBufferImpl* pImageBufferImpl = new (std::nothrow) _ImageBufferImpl();
+       SysTryReturnResult(NID_MEDIA, pImageBufferImpl != null, E_OUT_OF_MEMORY, "Create instance failed.");
+
+       r = pImageBufferImpl->Construct(srcImageBuf, destWidth, destHeight, scalingMethod);
+       SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
+               "[%s] Construct instance failed.", GetErrorMessage(r));
+
+       __pImpl = pImageBufferImpl;
+       return r;
+
+CATCH:
+       if (pImageBufferImpl != null)
+       {
+               delete pImageBufferImpl;
+               pImageBufferImpl = null;
+       }
+       return r;
+}
+
+
+ExifOrientation
+ImageBuffer::GetExifOrientation(void) const
+{
+       SysAssertf(__pImpl != null,
+               "Not yet constructed. Construct() should be called before use.");
+
+       return __pImpl->GetExifOrientation();
+}
+
 bool
 ImageBuffer::Equals(const Object& rhs) const
 {
@@ -258,6 +334,15 @@ ImageBuffer::GetBitmapN(BitmapPixelFormat pixelFormat, BufferScaling bufferScali
        return __pImpl->GetBitmapN(pixelFormat, bufferScaling);
 }
 
+Bitmap*
+ImageBuffer::GetBitmapN(BitmapPixelFormat pixelFormat, float destWidth, float destHeight) const
+{
+       SysAssertf(__pImpl != null,
+               "Not yet constructed. Construct() should be called before use.");
+
+       return __pImpl->GetBitmapN(pixelFormat, FloatDimension(destWidth, destHeight));
+}
+
 ByteBuffer*
 ImageBuffer::GetByteBufferN(MediaPixelFormat pixelFormat) const
 {
diff --git a/src/FMedia_ExifUtil.cpp b/src/FMedia_ExifUtil.cpp
deleted file mode 100644 (file)
index 29478a3..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-//
-// Open Service Platform
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-#include <math.h>
-#include <libexif/exif-byte-order.h>
-#include <libexif/exif-data-type.h>
-#include <libexif/exif-ifd.h>
-#include <libexif/exif-log.h>
-#include <libexif/exif-tag.h>
-#include <libexif/exif-content.h>
-#include <libexif/exif-mnote-data.h>
-#include <libexif/exif-mem.h>
-#include <FBaseSysLog.h>
-#include "FMedia_ExifUtil.h"
-
-namespace Tizen { namespace Media
-{
-
-const wchar_t* const EXIF_TAG_IMAGE_ORIENTATION = L"Exif.Orientation";
-const wchar_t* const EXIF_TAG_IMAGE_GPS_ALTITUDE = L"Exif.Gps.Altitude";
-const wchar_t* const EXIF_TAG_IMAGE_GPS_LONGITUDE = L"Exif.Gps.Longitude";
-const wchar_t* const EXIF_TAG_IMAGE_GPS_LATITUDE = L"Exif.Gps.Latitude";
-
-_ExifUtil::_ExifUtil()
-: __pExifData(null)
-, __pExifLog(null)
-, __orientation(-1)
-, __gpsLongitude(0.0)
-, __gpsLatitude(0.0)
-, __gpsAltitude(0.0)
-, __gpsLongitudeExist(false)
-, __gpsAltitudeExist(false)
-, __gpsLatitudeExist(false)
-, __orientationExist(false)
-{
-}
-
-_ExifUtil::~_ExifUtil()
-{
-       if (__pExifData)
-       {
-               exif_data_free(__pExifData);
-       }
-       if (__pExifLog)
-       {
-               exif_log_free(__pExifLog);
-       }
-}
-
-result _ExifUtil::Construct(const byte* pBuf, int length)
-{
-       result r = E_SUCCESS;
-
-       SysTryCatch(NID_MEDIA, pBuf != null, r = E_INVALID_DATA, E_INVALID_DATA, "[E_INVALID_DATA] Buffer is null. length: %d", length);
-
-       __pExifData = exif_data_new_from_data(pBuf, length);
-       SysTryCatch(NID_MEDIA, __pExifData != null, r = E_INVALID_DATA, E_INVALID_DATA, "[E_INVALID_DATA] exi data is null. length: %d", length);
-
-       __pExifLog = exif_log_new();
-       SysTryCatch(NID_MEDIA, __pExifLog != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] exif_log_new fail");
-
-#if defined _EXIF_UTIL_LOG_
-       //exif_log_set_func(__pExifLog, _ExifUtil::ExifLogFuncStatic, this);
-       //exif_data_log(__pExifData, __pExifLog);
-#endif
-       exif_data_foreach_content(__pExifData, _ExifUtil::ForEachContentStatic, this);
-       return r;
-
-CATCH:
-       if (__pExifLog)
-       {
-               exif_log_free(__pExifLog);
-       }
-       return r;
-}
-
-#if defined _EXIF_UTIL_LOG_
-//void _ExifUtil::ExifLogFuncStatic(ExifLog *log, ExifLogCode code, const char *domain, const char *format, va_list args, void *data)
-//{
-//     ((_ExifUtil*)data)->ExifLogFunc(log, code, domain, format, args);
-//}
-
-//void _ExifUtil::ExifLogFunc(ExifLog *log, ExifLogCode code, const char *domain, const char *format, va_list args)
-//{
-//     char msg[1024];
-//     vsprintf(msg, format, args);
-//     TLog("ExifLog : %s", msg);
-//}
-#endif
-
-void _ExifUtil::ForEachContentStatic(struct _ExifContent *pContent, void *pUserData)
-{
-       SysTryReturnVoidResult(NID_MEDIA, pContent != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] ExifContent instance is not available.");
-
-       _ExifUtil* pUtil = static_cast<_ExifUtil*>(pUserData);
-       SysTryReturnVoidResult(NID_MEDIA, pUtil != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _ExifUtil instance is not available.");
-
-       pUtil->ForEachContent(pContent);
-}
-
-void _ExifUtil::ForEachContent(struct _ExifContent *pContent)
-{
-       SysTryReturnVoidResult(NID_MEDIA, pContent != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] ExifContent instance is not available.");
-
-       exif_content_log(pContent, __pExifLog);
-       exif_content_dump(pContent, 0);
-
-       exif_content_foreach_entry(pContent, _ExifUtil::ForEachEntryStatic, this);
-}
-
-void _ExifUtil::ForEachEntryStatic(struct _ExifEntry *pEntry, void *pUserData)
-{
-       SysTryReturnVoidResult(NID_MEDIA, pEntry != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] ExifEntry instance is not available.");
-
-       _ExifUtil* pUtil = static_cast<_ExifUtil*>(pUserData);
-       SysTryReturnVoidResult(NID_MEDIA, pUtil != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _ExifUtil instance is not available.");
-
-       pUtil->ForEachEntry(pEntry);
-}
-
-void _ExifUtil::ForEachEntry(struct _ExifEntry *pEntry)
-{
-       SysTryReturnVoidResult(NID_MEDIA, pEntry != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] ExifEntry instance is not available.");
-       SysTryReturnVoidResult(NID_MEDIA, pEntry->parent != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Entry's parent instance is not available.");
-
-       const ExifByteOrder o = exif_data_get_byte_order (pEntry->parent->parent);
-       ExifRational exifRational;
-
-#if defined (_EXIF_UTIL_LOG_)
-       char value[1024];
-#endif
-
-       switch ((int)pEntry->tag)
-       {
-       case EXIF_TAG_ORIENTATION:
-               if (pEntry->format == EXIF_FORMAT_SHORT && pEntry->size == 2)
-               {
-                       __orientation = *(short*)(pEntry->data);
-                       __orientationExist = true;
-               }
-               break;
-
-       case EXIF_TAG_GPS_LATITUDE:
-               if (pEntry->format == EXIF_FORMAT_RATIONAL)
-               {
-               /*
-                       exifRational = exif_get_rational (pEntry->data, o);
-
-                       if (exifRational.denominator && exifRational.denominator != 1) {
-                               __gpsLatitude = (double)exifRational.numerator / (double)exifRational.denominator;
-                       }
-                       else
-                       {
-                               __gpsLatitude = (double)exifRational.numerator;
-                       }
-               */
-                       __gpsLatitude = 0.0;
-                       for (int i = 0; i < (int)pEntry->components; i++)
-                       {
-                               exifRational = exif_get_rational (pEntry->data + 8 * i, o);
-                               if (exifRational.denominator)
-                               {
-                                       __gpsLatitude += ((double)exifRational.numerator / (double)exifRational.denominator) / pow((float)60.0, i);
-                               }
-                               else
-                               {
-                                       __gpsLatitude += (double)exifRational.numerator / pow((float)60.0, i);
-                               }
-                       }
-                       __gpsLatitudeExist = true;
-               }
-               break;
-
-       case EXIF_TAG_GPS_LONGITUDE:
-               if (pEntry->format == EXIF_FORMAT_RATIONAL)
-               {
-               /*
-                       exifRational = exif_get_rational (pEntry->data, o);
-
-                       if (exifRational.denominator && exifRational.denominator != 1) {
-                               __gpsLatitude = (double)exifRational.numerator / (double)exifRational.denominator;
-                       } else {
-                               __gpsLatitude = (double)exifRational.numerator;
-                       }
-               */
-                       __gpsLongitude = 0.0;
-
-                       for (int i = 0; i < (int)pEntry->components; i++)
-                       {
-                               exifRational = exif_get_rational (pEntry->data + 8 * i, o);
-                               if (exifRational.denominator && exifRational.denominator != 1)
-                               {
-                                       __gpsLongitude += ((double)exifRational.numerator / (double)exifRational.denominator) / pow((float)60.0, i);
-                               }
-                               else
-                               {
-                                       __gpsLongitude += (double)exifRational.numerator / pow((float)60.0, i);
-                               }
-                       }
-                       __gpsLongitudeExist = true;
-               }
-               break;
-
-       case EXIF_TAG_GPS_ALTITUDE:
-               if (pEntry->format == EXIF_FORMAT_RATIONAL)
-               {
-                       exifRational = exif_get_rational (pEntry->data, o);
-
-                       if (exifRational.denominator && exifRational.denominator != 1)
-                       {
-                               __gpsAltitude = (double)exifRational.numerator / (double)exifRational.denominator;
-                       }
-                       else
-                       {
-                               __gpsAltitude = (double)exifRational.numerator;
-                       }
-                       __gpsAltitudeExist = true;
-               }
-               break;
-
-       default:
-               break;
-       }
-}
-
-result _ExifUtil::GetValue(const Tizen::Base::String& key, int &value)
-{
-       if (key.Equals(EXIF_TAG_IMAGE_ORIENTATION, true))
-       {
-               SysTryReturn(NID_MEDIA, __orientationExist, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] bool instance is not available. Orientation value was not found.");
-               value = __orientation;
-       }
-       else
-       {
-               SysLogException(NID_MEDIA, E_INVALID_ARG, "[E_INVALID_ARG] Key:%S was wrong.", key.GetPointer());
-               return E_INVALID_ARG;
-       }
-
-       return E_SUCCESS;
-}
-
-result _ExifUtil::GetValue(const Tizen::Base::String& key, double &value)
-{
-       if (key.Equals(EXIF_TAG_IMAGE_GPS_ALTITUDE, true))
-       {
-               SysTryReturn(NID_MEDIA, __gpsAltitudeExist, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] bool instance is not available. Altitude value was not found.");
-               value = __gpsAltitude;
-       }
-       else if (key.Equals(EXIF_TAG_IMAGE_GPS_LONGITUDE, true))
-       {
-               SysTryReturn(NID_MEDIA, __gpsLongitude, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] bool instance is not available. Longitude value was not found.");
-               value = __gpsLongitude;
-       } else if (key.Equals(EXIF_TAG_IMAGE_GPS_LATITUDE, true))
-       {
-               SysTryReturn(NID_MEDIA, __gpsLatitude, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] bool instance is not available. Latitude value was not found.");
-               value = __gpsLatitude;
-       } else
-       {
-               SysLogException(NID_MEDIA, E_INVALID_ARG, "[E_INVALID_ARG] Key:%S was wrong.", key.GetPointer());
-               return E_INVALID_ARG;
-       }
-
-       return E_SUCCESS;
-}
-
-}}
-
index 00e8831..c347803 100644 (file)
 #include "FMedia_ImageEncoder.h"
 #include "FMedia_ColorConverter.h"
 #include "FMedia_ExifUtil.h"
+#include "FUi_CoordinateSystemUtils.h"
+#include "FGrp_BitmapImpl.h"
 
 using namespace Tizen::Graphics;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Io;
 using namespace Tizen::App;
+using namespace Tizen::Ui;
 
 namespace Tizen { namespace Media
 {
 
 #define ISSUPPORTED(x)                                                                                                                 \
-    ((x == MEDIA_PIXEL_FORMAT_YUV420P) || (x == MEDIA_PIXEL_FORMAT_BGRA8888) ||        \
+       ((x == MEDIA_PIXEL_FORMAT_YUV420P) || (x == MEDIA_PIXEL_FORMAT_BGRA8888) ||     \
        (x == MEDIA_PIXEL_FORMAT_RGB565LE) || (x == MEDIA_PIXEL_FORMAT_GRAY))
 
-enum _ExifOrientation
-{
-       EXIF_ORIENTATION_TOP_LEFT = 0x01,    /**< The row #0 is top, column #0 is left */
-       EXIF_ORIENTATION_TOP_RIGHT,      /**< The row #0 is top, column #0 is right */
-       EXIF_ORIENTATION_BOTTOM_RIGHT,   /**< The row #0 is bottom, column #0 is right */
-       EXIF_ORIENTATION_BOTTOM_LEFT,    /**< The row #0 is bottom, column #0 is left */
-       EXIF_ORIENTATION_LEFT_TOP,       /**< The row #0 is left, column #0 is top */
-       EXIF_ORIENTATION_RIGHT_TOP,      /**< The row #0 is right, column #0 is top */
-       EXIF_ORIENTATION_RIGHT_BOTTOM,   /**< The row #0 is right, column #0 is bottom */
-       EXIF_ORIENTATION_LEFT_BOTTOM,    /**< The row #0 is left, column #0 is bottom */
-};
-
 typedef struct {
        ImageRotationType rotateType;
        ImageFlipType flipType;
@@ -79,6 +70,18 @@ static const _ImageExifInfo _IMAGE_ROTATE_FLIP_MAP[] = {
        { IMAGE_ROTATION_270, IMAGE_FLIP_NONE,       true  }  /* LEFT_BOTTOM  */
 };
 
+static const ExifOrientation _ORIENTATION_MAP[] ={
+       EXIF_ORIENTATION_TOP_LEFT,
+       EXIF_ORIENTATION_TOP_LEFT,
+       EXIF_ORIENTATION_TOP_RIGHT,
+       EXIF_ORIENTATION_BOTTOM_RIGHT,
+       EXIF_ORIENTATION_BOTTOM_LEFT,
+       EXIF_ORIENTATION_LEFT_TOP,
+       EXIF_ORIENTATION_RIGHT_TOP,
+       EXIF_ORIENTATION_RIGHT_BOTTOM,
+       EXIF_ORIENTATION_LEFT_BOTTOM
+};
+
 static const MediaPixelFormat _IMAGE_BUFFER_PIXEL_FORMATS[] =
 {
        MEDIA_PIXEL_FORMAT_RGB565LE,
@@ -90,6 +93,7 @@ _ImageBufferImpl::_ImageBufferImpl(void)
        : __pBuffer(null)
        , __width(0)
        , __height(0)
+       , __orientation(EXIF_ORIENTATION_TOP_LEFT)
        , __pixelFormat(MEDIA_PIXEL_FORMAT_NONE)
        , __isLocked(false)
 {
@@ -117,13 +121,11 @@ _ImageBufferImpl::Construct(int width, int height, MediaPixelFormat pixelFormat)
                "[E_INVALID_ARG] Check inputs: (%d x %d), pixel format (%d).",
                __width, __height, __pixelFormat);
 
-       __pBuffer.reset(new (std::nothrow) ByteBuffer);
+       __pBuffer.reset(new (std::nothrow) byte[length]);
        SysTryReturn(NID_MEDIA, __pBuffer.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
                "[E_OUT_OF_MEMORY] Construct instance failed.");
-
-       r = __pBuffer->Construct(length);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r,
-               "[%s] Construct instance failed.", GetErrorMessage(r));
+       memset(__pBuffer.get(), 0, length);
+       __bufSize = length;
 
        return r;
 }
@@ -145,6 +147,8 @@ _ImageBufferImpl::Construct(int width, int height, MediaPixelFormat pixelFormat,
                "[E_INVALID_ARG] Pixelformat is not supported : %d.", pixelFormat);
 
        reqBufferSize = _ImageUtil::GetBufferSize(pixelFormat, width, height);
+       SysTryReturn(NID_MEDIA, reqBufferSize > 0, GetLastResult(), GetLastResult(),
+                       "[%s] Could not get output buffer size.", GetErrorMessage(GetLastResult()));
 
        if (pData != null)
        {
@@ -157,22 +161,16 @@ _ImageBufferImpl::Construct(int width, int height, MediaPixelFormat pixelFormat,
        __height = height;
        __pixelFormat = pixelFormat;
 
-       __pBuffer.reset(new (std::nothrow) ByteBuffer);
+       __pBuffer.reset(new (std::nothrow) byte[reqBufferSize]);
        SysTryReturn(NID_MEDIA, __pBuffer.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
                "[E_OUT_OF_MEMORY] Construct instance failed.");
-
-       r = __pBuffer->Construct(reqBufferSize);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r,
-               "[%s] Construct instance failed.", GetErrorMessage(r));
+       memset(__pBuffer.get(), 0, reqBufferSize);
+       __bufSize = reqBufferSize;
 
        if (pData != null)
        {
-               r = __pBuffer->SetArray(pData, 0, reqBufferSize);
-               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r,
-                       "[%s] SetArray  for buffer %x of length %d failed.", GetErrorMessage(r),
-                       pData, reqBufferSize);
+               memcpy(__pBuffer.get(), pData, reqBufferSize);
        }
-       __pBuffer->Flip();
        return r;
 }
 
@@ -193,11 +191,10 @@ _ImageBufferImpl::Construct(const Tizen::Base::String &srcImagePath, const Recta
 result
 _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, const Tizen::Graphics::Rectangle *pDecodingRegion, bool autoRotate)
 {
-
        result r = E_SUCCESS;
 
        _ImageDecoder dec;
-       std::unique_ptr<ByteBuffer> pDstBuf;
+       std::unique_ptr<byte[]> pDstBuf;
        Tizen::Graphics::Rectangle transformRegion;
        int orientationInfo = 0;
 
@@ -209,15 +206,13 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, const Ti
        SysTryReturn(NID_MEDIA, __pixelFormat != MEDIA_PIXEL_FORMAT_NONE, r, r,
                "[%s] GetPixelFormat failed.", GetErrorMessage(r));
 
-       if(autoRotate == true)
-       {
-               _ExifUtil imgExif;
-               imgExif.Construct(srcImageBuf.GetPointer(), srcImageBuf.GetCapacity());
-               imgExif.GetValue(EXIF_TAG_IMAGE_ORIENTATION, orientationInfo);
-               // imgExif.GetValue() will return "r = E_OBJ_NOT_FOUND" if it could not be found exif infomation.
-               // However, the result should be decided by result of construct in this function.
-               SetLastResult(E_SUCCESS);
-       }
+       _ExifUtil imgExif;
+       imgExif.Construct(srcImageBuf.GetPointer(), srcImageBuf.GetCapacity());
+       imgExif.GetValue(EXIF_TAG_IMAGE_ORIENTATION, orientationInfo);
+       // imgExif.GetValue() will return "r = E_OBJ_NOT_FOUND" if it could not be found exif infomation.
+       // However, the result should be decided by result of construct in this function.
+       SetLastResult(E_SUCCESS);
+       __orientation = _ORIENTATION_MAP[orientationInfo];
 
        if (pDecodingRegion != null)
        {
@@ -240,7 +235,7 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, const Ti
                }
                else
                {
-               SysTryReturn(NID_MEDIA, imgWidth >= (pDecodingRegion->x + pDecodingRegion->width)
+                       SysTryReturn(NID_MEDIA, imgWidth >= (pDecodingRegion->x + pDecodingRegion->width)
                                && imgHeight >= (pDecodingRegion->y + pDecodingRegion->height),
                                E_INVALID_ARG, E_INVALID_ARG,
                                "[E_INVALID_ARG] imageWidth = %d, imageHeight = %d, x = %d, y = %d, width = %d, height = %d",
@@ -308,30 +303,32 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, const Ti
 
                if (r == E_SUCCESS)
                {
-                       __pBuffer.reset(dec.DecodeN());
-                       r = GetLastResult();
-                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] DecodeN failed.",
-                               GetErrorMessage(r));
+                       __pBuffer.reset(dec.DecodeN(__bufSize));
                        SysTryReturn(NID_MEDIA, __pBuffer.get() != null, r, r,
                                "[%s] DecodeN returned empty buffer.", GetErrorMessage(r));
                }
                else if (r == E_UNSUPPORTED_OPERATION)
                {
                        // crop image
-                       ByteBuffer *pTmpBuf = null;
+                       std::unique_ptr<byte[]> pTmpbyte;
 
-                       __pBuffer.reset(dec.DecodeN());
+                       pTmpbyte.reset(dec.DecodeN(__bufSize));
                        r = GetLastResult();
-                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagated. ", GetErrorMessage(r));
+                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] DecodeN failed.", GetErrorMessage(r));
+                       SysTryReturn(NID_MEDIA, pTmpbyte.get() != null, r, r,
+                               "[%s] DecodeN returned empty buffer.", GetErrorMessage(r));
+
+                       __pBuffer.reset(_ImageUtil::CropN(pTmpbyte.get(), __pixelFormat, imgWidth, imgHeight,
+                               transformRegion.x, transformRegion.y, transformRegion.width, transformRegion.height));
 
-                       pTmpBuf = _ImageUtil::CropN(*__pBuffer.get(), __pixelFormat, imgWidth, imgHeight,
-                               transformRegion.x, transformRegion.y, transformRegion.width, transformRegion.height);
-                       SysTryReturn(NID_MEDIA, pTmpBuf != null, GetLastResult(), GetLastResult(),
-                               "[%s] Crop:%x %d %d %d %d %d %d %d", GetErrorMessage(GetLastResult()), __pBuffer->GetPointer(),
-                       __pixelFormat, imgWidth, imgHeight, pDecodingRegion->x, pDecodingRegion->y,
+                       SysTryReturn(NID_MEDIA, __pBuffer.get() != null, GetLastResult(), GetLastResult(),
+                               "[%s] Crop:%x %d %d %d %d %d %d %d", GetErrorMessage(GetLastResult()), pTmpbyte.get(),
+                               __pixelFormat, imgWidth, imgHeight, pDecodingRegion->x, pDecodingRegion->y,
                                pDecodingRegion->width, pDecodingRegion->height);
 
-                       __pBuffer.reset(pTmpBuf);
+                       __bufSize = _ImageUtil::GetBufferSize(__pixelFormat, pDecodingRegion->width, pDecodingRegion->height);
+                       SysTryReturn(NID_MEDIA, __bufSize > 0, GetLastResult(), GetLastResult(),
+                       "[%s] Could not get output buffer size.", GetErrorMessage(GetLastResult()));
                }
        }
        else
@@ -340,19 +337,19 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, const Ti
                SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] GetDimension failed.",
                        GetErrorMessage(r));
 
-               __pBuffer.reset(dec.DecodeN());
+               __pBuffer.reset(dec.DecodeN(__bufSize));
                r = GetLastResult();
-               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] DecodeN failed.",
-                       GetErrorMessage(r));
-               SysTryReturn(NID_MEDIA, __pBuffer.get() != null, r, r,
-                       "[%s] DecodeN returned empty buffer.", GetErrorMessage(r));
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] DecodeN failed.", GetErrorMessage(r));
+               SysTryReturn(NID_MEDIA, __pBuffer.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY] Propagated.");
        }
 
        if (autoRotate == true)
        {
-               ByteBuffer *pTmpBuf = null;
-               int tempWidth = 0;
-               int length = 0;
+               int dstWidth = 0;
+               int dstHeight = 0;
+
+               __orientation = EXIF_ORIENTATION_TOP_LEFT;
 
                if (orientationInfo == EXIF_ORIENTATION_TOP_LEFT || orientationInfo == 0)
                {
@@ -364,33 +361,26 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, const Ti
                        return E_SUCCESS;
                }
 
-               pDstBuf.reset(new (std::nothrow) ByteBuffer());
+               pDstBuf.reset(new (std::nothrow) byte[__bufSize]);
                SysTryReturn(NID_MEDIA, pDstBuf.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
 
-               length = _ImageUtil::GetBufferSize(__pixelFormat, __width, __height);
-
-               pDstBuf->Construct(length);
-               pDstBuf->SetLimit(length);
-               pDstBuf->SetPosition(0);
-
                ImageRotationType rotateType = _IMAGE_ROTATE_FLIP_MAP[orientationInfo].rotateType;
                ImageFlipType flipType = _IMAGE_ROTATE_FLIP_MAP[orientationInfo].flipType;
 
-               r = _ImageUtil::Rotate(*__pBuffer.get(), __pixelFormat, __width, __height, *pDstBuf.get(), rotateType);
+               pDstBuf.reset(_ImageUtil::RotateN(__pBuffer.get(), __pixelFormat, __width, __height, rotateType, dstWidth, dstHeight));
+               r = GetLastResult();
                SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] _ImageUtil:Resize", GetErrorMessage(r));
-               if(_IMAGE_ROTATE_FLIP_MAP[orientationInfo].dimensionSwitch == true)
-               {
-                       tempWidth = __width;
-                       __width = __height;
-                       __height =  tempWidth;
-               }
 
-               __pBuffer.swap(pDstBuf);
+               __width = dstWidth;
+               __height = dstHeight;
 
+               __pBuffer.swap(pDstBuf);
                if (flipType != IMAGE_FLIP_NONE)
                {
-                       r = _ImageUtil::Flip(*__pBuffer.get(), __pixelFormat, __width, __height, *pDstBuf, flipType);
+                       pDstBuf.reset(_ImageUtil::FlipN(__pBuffer.get(), __pixelFormat, __width, __height, flipType));
+                       r = GetLastResult();
                        SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] _ImageUtil:Flip", GetErrorMessage(r));
+
                        __pBuffer.swap(pDstBuf);
                }
        }
@@ -421,29 +411,84 @@ _ImageBufferImpl::Construct(const Bitmap &srcBitmap)
 
        __pixelFormat = _ImageUtilImpl::ToMediaPixelFormat(srcBitmap.GetPixelColorFormat());
 
-       __pBuffer.reset(new (std::nothrow) ByteBuffer);
-       SysTryCatch(NID_MEDIA, __pBuffer.get(), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+       __pBuffer.reset(new (std::nothrow) byte[length]);
+       SysTryCatch(NID_MEDIA, __pBuffer.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
                "[E_OUT_OF_MEMORY] Construct instance failed.");
-
-       r = __pBuffer->Construct(length);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r,
-               "[%s] Construct instance failed.", GetErrorMessage(r));
-       r = __pBuffer->SetArray((byte*)info.pPixels, 0, length);
-       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagated.", GetErrorMessage(r));
+       __bufSize = length;
+       memcpy(__pBuffer.get(), (byte*)info.pPixels, length);
 
        r = pTmpBmp->Unlock();
        SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Bitmap.Unlock failed.", GetErrorMessage(r));
 
-       __pBuffer->Flip();
-
        return r;
-
 CATCH:
        pTmpBmp->Unlock();
 
        return r;
 }
 
+
+
+
+result
+_ImageBufferImpl::Construct(const Tizen::Base::String &srcImagePath, int destWidth, int destHeight, ImageScalingMethod scalingMethod)
+{
+       result r = E_SUCCESS;
+
+       std::unique_ptr<ByteBuffer> pBuf;
+       pBuf.reset(_MediaUtil::FileToBufferN(srcImagePath));
+       SysTryReturn(NID_MEDIA, pBuf.get() != null, GetLastResult(), GetLastResult(),
+                          "[%s] FileToBufferN %S", GetErrorMessage(GetLastResult()), srcImagePath.GetPointer());
+       r = Construct(*pBuf.get(), destWidth, destHeight, scalingMethod);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] ImageBuffer construct failed.", GetErrorMessage(r));
+       return r;
+}
+
+result
+_ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, int destWidth, int destHeight, ImageScalingMethod scalingMethod)
+{
+       result r = E_SUCCESS;
+       int orientationInfo = 0;
+       _ImageDecoder dec;
+       std::unique_ptr<byte[]> pDstBuf;
+       Tizen::Graphics::Rectangle transformRegion;
+
+       r = dec.Construct(srcImageBuf);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
+
+       __pixelFormat = dec.GetPixelFormat();
+       r = GetLastResult();
+       SysTryReturn(NID_MEDIA, __pixelFormat != MEDIA_PIXEL_FORMAT_NONE, r, r,
+               "[%s] GetPixelFormat failed.", GetErrorMessage(r));
+
+       _ExifUtil imgExif;
+       imgExif.Construct(srcImageBuf.GetPointer(), srcImageBuf.GetCapacity());
+       imgExif.GetValue(EXIF_TAG_IMAGE_ORIENTATION, orientationInfo);
+       // imgExif.GetValue() will return "r = E_OBJ_NOT_FOUND" if it could not be found exif infomation.
+       // However, the result should be decided by result of construct in this function.
+       SetLastResult(E_SUCCESS);
+
+       __orientation = _ORIENTATION_MAP[orientationInfo];
+
+       dec.SetOutputDimension(destWidth, destHeight, false);
+
+       __pBuffer.reset(dec.DecodeN(__bufSize, scalingMethod));
+       r = GetLastResult();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] DecodeN failed.", GetErrorMessage(r));
+       SysTryReturn(NID_MEDIA, __pBuffer.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+               "[E_OUT_OF_MEMORY] Propagated.");
+
+       r = dec.GetDimension(__width, __height);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] GetDimension failed.",
+               GetErrorMessage(r));
+
+       __bufSize = _ImageUtil::GetBufferSize(__pixelFormat, __width, __height);
+       SysTryReturn(NID_MEDIA, __bufSize > 0, GetLastResult(), GetLastResult(),
+                       "[%s] Could not get output buffer size.", GetErrorMessage(GetLastResult()));
+       return r;
+}
+
+
 bool
 _ImageBufferImpl::Equals(ImageBuffer* pRhs) const
 {
@@ -492,7 +537,7 @@ _ImageBufferImpl::Equals(ImageBuffer* pRhs) const
                                        "[%s] Could not lock this ImageBuffer contents.", GetErrorMessage(r));
 
                                // Check if contents are equal.
-                               if ((__pixelFormat != pixFmtOther) || (__pBuffer->GetCapacity() != lengthOther))
+                               if ((__pixelFormat != pixFmtOther) || (__bufSize != lengthOther))
                                {
                                        out = false;
                                }
@@ -518,8 +563,12 @@ int
 _ImageBufferImpl::GetHashCode() const
 {
        int hashCode = 0;
+       int len = __bufSize / sizeof(len);
 
-       hashCode = __pBuffer->GetHashCode();
+       for (int i = 0; i < len; ++i)
+       {
+               hashCode = (hashCode << 5) - hashCode + static_cast <int>(__pBuffer[(i * sizeof(hashCode))]);
+       }
 
        hashCode = (hashCode ^ (__width * __height)) | (hashCode & __pixelFormat);
 
@@ -544,6 +593,12 @@ _ImageBufferImpl::GetPixelFormat() const
        return __pixelFormat;
 }
 
+ExifOrientation
+_ImageBufferImpl::GetExifOrientation(void) const
+{
+       return __orientation;
+}
+
 result
 _ImageBufferImpl::Lock(byte* &data, int &length, MediaPixelFormat &pixelFormat)
 {
@@ -552,7 +607,7 @@ _ImageBufferImpl::Lock(byte* &data, int &length, MediaPixelFormat &pixelFormat)
        SysTryReturn(NID_MEDIA, __isLocked != true, E_INVALID_STATE, E_INVALID_STATE,
                "[E_INVALID_STATE] Instance is locked. Unlock to use.");
 
-       data = const_cast<byte *>(__pBuffer->GetPointer());
+       data = const_cast<byte *>(__pBuffer.get());
        length = _ImageUtil::GetBufferSize(__pixelFormat, __width, __height);
        pixelFormat = __pixelFormat;
 
@@ -585,7 +640,7 @@ _ImageBufferImpl::EncodeToBufferN(ImageFormat destImageFormat, int quality) cons
                "[E_INVALID_STATE] Instance is locked. Unlock to use.");
 
        inLength = _ImageUtil::GetBufferSize(__pixelFormat, __width, __height);
-       pBuf = _ImageEncoder::EncodeN(destImageFormat, (const byte*)__pBuffer->GetPointer(), inLength, __width, __height,
+       pBuf = _ImageEncoder::EncodeN(destImageFormat, (const byte*)__pBuffer.get(), inLength, __width, __height,
                __pixelFormat, quality);
        SysTryReturn(NID_MEDIA, pBuf != null, null, GetLastResult(), "[%s] Propagated. ", GetErrorMessage(GetLastResult()));
 
@@ -646,7 +701,12 @@ _ImageBufferImpl::GetBitmapN(BitmapPixelFormat pixelFormat, BufferScaling buffer
        }
        else
        {
-               r = pOutBitmap->Construct(*__pBuffer, Dimension(__width, __height), pixelFormat, bufferScaling);
+               std::unique_ptr<ByteBuffer> pTmpByteBuffer (new (std::nothrow) ByteBuffer());
+               r = pTmpByteBuffer->Construct(__pBuffer.get(), 0, __bufSize, __bufSize);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r,
+                       "[%s] Construct instance failed.", GetErrorMessage(r));
+
+               r = pOutBitmap->Construct(*pTmpByteBuffer.get(), Dimension(__width, __height), pixelFormat, bufferScaling);
        }
 
        SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated.",
@@ -654,6 +714,57 @@ _ImageBufferImpl::GetBitmapN(BitmapPixelFormat pixelFormat, BufferScaling buffer
        return pOutBitmap.release();
 }
 
+Bitmap*
+_ImageBufferImpl::GetBitmapN(BitmapPixelFormat pixelFormat, const FloatDimension &destDim) const
+{
+       result r = E_SUCCESS;
+       std::unique_ptr<Bitmap> pOutBitmap;
+       std::unique_ptr<ByteBuffer> pConverted;
+       MediaPixelFormat inPixelFormat = MEDIA_PIXEL_FORMAT_NONE;
+       Dimension convertDim;
+
+       SysTryReturn(NID_MEDIA, !__isLocked, null, E_INVALID_STATE,
+               "[E_INVALID_STATE] Instance is locked. Unlock to use.");
+
+       inPixelFormat = _ImageUtilImpl::ToMediaPixelFormat(pixelFormat);
+       SysTryReturn(NID_MEDIA, (inPixelFormat > MEDIA_PIXEL_FORMAT_NONE) && (inPixelFormat <= MEDIA_PIXEL_FORMAT_GRAY),
+                                null, E_INVALID_ARG, "[E_INVALID_ARG] Pixel format is invalid.", inPixelFormat);
+
+       pOutBitmap.reset(new (std::nothrow) Bitmap);
+       SysTryReturn(NID_MEDIA, pOutBitmap.get() != null, null, E_OUT_OF_MEMORY,
+               "[E_OUT_OF_MEMORY] Propagated.");
+
+       convertDim.width = _CoordinateSystemUtils::ConvertToInteger(destDim.width);
+       convertDim.height = _CoordinateSystemUtils::ConvertToInteger(destDim.height);
+
+       std::unique_ptr<ByteBuffer> pTmpByteBuffer (new (std::nothrow) ByteBuffer());
+       r = pTmpByteBuffer->Construct(__pBuffer.get(), 0, __bufSize, __bufSize);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r,
+                               "[%s] Construct instance failed.", GetErrorMessage(r));
+
+       if (inPixelFormat == __pixelFormat && convertDim.width == __width && convertDim.height == __height)
+       {
+               pOutBitmap.reset(_BitmapImpl::GetNonScaledBitmapN(*pTmpByteBuffer.get(), convertDim, pixelFormat));
+       }
+       else
+       {
+               std::unique_ptr<ByteBuffer> pOutBuf;
+               _ColorConverter cvt;
+
+               r = cvt.Construct(__pixelFormat, __width, __height, inPixelFormat, convertDim.width, convertDim.height);
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated.", GetErrorMessage(r));
+
+               pOutBuf.reset(cvt.ConvertN(*pTmpByteBuffer));
+               r = GetLastResult();
+               SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated.", GetErrorMessage(r));
+
+               pOutBitmap.reset(_BitmapImpl::GetNonScaledBitmapN(*pOutBuf.get(), convertDim, pixelFormat));
+       }
+
+       SysTryReturn(NID_MEDIA, pOutBitmap.get() != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(GetLastResult()));
+       return pOutBitmap.release();
+}
+
 ByteBuffer*
 _ImageBufferImpl::GetByteBufferN(MediaPixelFormat inPixelFormat) const
 {
@@ -669,6 +780,11 @@ _ImageBufferImpl::GetByteBufferN(MediaPixelFormat inPixelFormat) const
        SysTryReturn(NID_MEDIA, IsSupportedPixelFormat(inPixelFormat) == true , null, E_UNSUPPORTED_FORMAT,
                "[E_UNSUPPORTED_FORMAT] The specified pixelFormat is not supported.")
 
+       std::unique_ptr<ByteBuffer> pTmpByteBuffer (new (std::nothrow) ByteBuffer());
+       r = pTmpByteBuffer->Construct(__pBuffer.get(), 0, __bufSize, __bufSize);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r,
+                       "[%s] Construct instance failed.", GetErrorMessage(r));
+
        if (inPixelFormat != __pixelFormat)
        {
                // Convert raw data to the required pixel format.
@@ -678,7 +794,7 @@ _ImageBufferImpl::GetByteBufferN(MediaPixelFormat inPixelFormat) const
                        inPixelFormat, __width, __height);
                SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated.", GetErrorMessage(r));
 
-               pOutBuf.reset(cvt.ConvertN(*__pBuffer));
+               pOutBuf.reset(cvt.ConvertN(*pTmpByteBuffer));
                r = GetLastResult();
                SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated.", GetErrorMessage(r));
        }
@@ -688,7 +804,7 @@ _ImageBufferImpl::GetByteBufferN(MediaPixelFormat inPixelFormat) const
                SysTryReturn(NID_MEDIA, pOutBuf.get() != null, null, E_OUT_OF_MEMORY,
                        "[E_OUT_OF_MEMORY] Propagated.");
 
-               r = pOutBuf->Construct(*__pBuffer);
+               r = pOutBuf->Construct(*pTmpByteBuffer);
                SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r,
                        "[%s] Propagated.", GetErrorMessage(r));
        }
@@ -701,7 +817,6 @@ ImageBuffer*
 _ImageBufferImpl::CloneN() const
 {
        std::unique_ptr<ImageBuffer> pImgBuffer;
-       _ImageBufferImpl* pImgBufferImpl = null;
        result r = E_SUCCESS;
        byte* pData = null;
        int length = 0;
@@ -728,7 +843,6 @@ ImageBuffer*
 _ImageBufferImpl::ConvertPixelFormatN(MediaPixelFormat pixelFormat) const
 {
        std::unique_ptr<ImageBuffer> pImgBuffer;
-       _ImageBufferImpl* pImgBufferImpl = null;
        result r = E_SUCCESS;
        byte* pData = null;
        std::unique_ptr<byte[]> pDataConvert;
@@ -784,7 +898,6 @@ ImageBuffer*
 _ImageBufferImpl::ResizeN(int width, int height) const
 {
        std::unique_ptr<ImageBuffer> pImgBuffer;
-       _ImageBufferImpl* pImgBufferImpl = null;
        result r = E_SUCCESS;
        byte* pData = null;
        std::unique_ptr<byte[]> pDataResized;
@@ -844,7 +957,6 @@ ImageBuffer*
 _ImageBufferImpl::FlipN(ImageFlipType flipType) const
 {
        std::unique_ptr<ImageBuffer> pImgBuffer;
-       _ImageBufferImpl* pImgBufferImpl = null;
        result r = E_SUCCESS;
        byte* pData = null;
        std::unique_ptr<byte[]> pDataFlip;
@@ -898,7 +1010,6 @@ ImageBuffer*
 _ImageBufferImpl::RotateN(ImageRotationType rotationType) const
 {
        std::unique_ptr<ImageBuffer> pImgBuffer;
-       _ImageBufferImpl* pImgBufferImpl = null;
        result r = E_SUCCESS;
        byte* pData = null;
        std::unique_ptr<byte[]> pDataRotate;
@@ -955,7 +1066,6 @@ ImageBuffer*
 _ImageBufferImpl::CropN(int x, int y, int width, int height) const
 {
        std::unique_ptr<ImageBuffer> pImgBuffer;
-       _ImageBufferImpl* pImgBufferImpl = null;
        result r = E_SUCCESS;
        byte* pData = null;
        std::unique_ptr<byte[]> pDataCropped;
index 4d62299..dfb27b8 100644 (file)
 #include <FBaseSysLog.h>
 #include "FMedia_MediaUtil.h"
 #include "FMedia_ImageImpl.h"
+#include "FMedia_ImageUtil.h"
 #include "FMedia_ImageUtilImpl.h"
 #include "FMedia_ImageDecoder.h"
 #include "FMedia_ImageEncoder.h"
 #include "FMedia_ImageUriDataFactory.h"
+#include "FGrp_BitmapImpl.h"
+#include "FUi_CoordinateSystemUtils.h"
+
 
 using namespace Tizen::Graphics;
 using namespace Tizen::Base;
 using namespace Tizen::Io;
+using namespace Tizen::Ui;
 
 namespace Tizen { namespace Media
 {
@@ -85,43 +90,92 @@ _ImageImpl::Construct(void)
        return E_SUCCESS;
 }
 
+Bitmap* 
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat)
+{
+       std::unique_ptr<ByteBuffer> pBuf;
+       Bitmap* pBmp = null;
+
+       pBuf.reset(_MediaUtil::FileToBufferN(srcImagePath));
+       SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
+                          "[%s] FileToBufferN %S", GetErrorMessage(GetLastResult()), srcImagePath.GetPointer());
+
+       pBmp = DecodeToBitmapN(*pBuf.get(), pixelFormat);
+       return pBmp;
+}
+
+Bitmap* 
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat)
+{
+       result r = E_SUCCESS;
+       std::unique_ptr<ByteBuffer> pBuf;
+       std::unique_ptr<Bitmap> pBmp;
+       Dimension outDim;
+
+       _ImageDecoder dec;
+
+       r = dec.Construct(srcImageBuf, _ImageUtilImpl::ToMediaPixelFormat(pixelFormat));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
+
+       pBuf.reset(dec.DecodeN());
+       SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
+                          "[%s] Propagated", GetErrorMessage(GetLastResult()));
+       r = GetLastResult();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+       r = dec.GetDimension(outDim.width, outDim.height);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+       pBmp.reset(new (std::nothrow) Bitmap);
+       SysTryReturn(NID_MEDIA, pBmp != null, null, E_OUT_OF_MEMORY,
+                          "[%s] new Bitmap", GetErrorMessage(GetLastResult()));
+       r = pBmp->Construct(*pBuf.get(), outDim, pixelFormat, BUFFER_SCALING_AUTO);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+       SetLastResult(E_SUCCESS);
+       return pBmp.release();
+}
+
 Bitmap*
-_ImageImpl::DecodeToBitmapN(const String& srcImgPath, BitmapPixelFormat pixelFormat,
-                                                       const Tizen::Graphics::Dimension &dstDim,
-                                                       Tizen::Graphics::BufferScaling bufferScaling,
-                                                       ImageFormat imgFormat, bool keepAspectRatio)
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, const Tizen::Graphics::Dimension &destDim,
+                                                       Tizen::Graphics::BufferScaling bufferScaling)
 {
        std::unique_ptr<ByteBuffer> pBuf;
        Bitmap* pBmp = null;
 
-       pBuf.reset(_MediaUtil::FileToBufferN(srcImgPath));
+       pBuf.reset(_MediaUtil::FileToBufferN(srcImagePath));
        SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
-                          "[%s] FileToBufferN %S", GetErrorMessage(GetLastResult()), srcImgPath.GetPointer());
+                          "[%s] FileToBufferN %S", GetErrorMessage(GetLastResult()), srcImagePath.GetPointer());
 
-       pBmp = DecodeToBitmapN(*pBuf.get(), pixelFormat, dstDim, bufferScaling, imgFormat, keepAspectRatio);
+       pBmp = DecodeToBitmapN(*pBuf.get(), pixelFormat, destDim, bufferScaling);
        return pBmp;
 }
 
-Tizen::Graphics::Bitmap*
-_ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf,
-                                                       Tizen::Graphics::BitmapPixelFormat pixelFormat,
-                                                       const Tizen::Graphics::Dimension &dstDim,
-                                                       Tizen::Graphics::BufferScaling bufferScaling,
-                                                       ImageFormat imgFormat, bool keepAspectRatio)
+Bitmap*
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat, const Tizen::Graphics::Dimension &destDim,
+                                                       Tizen::Graphics::BufferScaling bufferScaling)
 {
        result r = E_SUCCESS;
        std::unique_ptr<ByteBuffer> pBuf;
        std::unique_ptr<Bitmap> pBmp;
        Dimension outDim;
 
-       //SysTryCatch(NID_MEDIA, IS_VALID_BITMAP_PIXEL(pixelFormat), , E_INVALID_ARG,
-       //                 "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
-       //SysTryCatch(NID_MEDIA, IS_VALID_DIMENSION(dstDim), , E_OUT_OF_RANGE,
-       //                 "[E_OUT_OF_RANGE] dest dimension:%d,%d", dstDim.width, dstDim.height);
+       _ImageDecoder dec;
 
-       pBuf.reset(DecodeToBufferN(srcImageBuf, outDim, dstDim, pixelFormat, imgFormat, keepAspectRatio));
+       r = dec.Construct(srcImageBuf, _ImageUtilImpl::ToMediaPixelFormat(pixelFormat));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
+
+       // Reset decoder output demension
+       dec.SetOutputDimension(destDim.width, destDim.height, true);
+
+       pBuf.reset(dec.DecodeN());
        SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
                           "[%s] Propagated", GetErrorMessage(GetLastResult()));
+       r = GetLastResult();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+       r = dec.GetDimension(outDim.width, outDim.height);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
 
        pBmp.reset(new (std::nothrow) Bitmap);
        SysTryReturn(NID_MEDIA, pBmp != null, null, E_OUT_OF_MEMORY,
@@ -133,6 +187,64 @@ _ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf,
        return pBmp.release();
 }
 
+Bitmap*
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat,
+                                                       const Tizen::Graphics::FloatDimension &destDim)
+{
+       result r = E_SUCCESS;
+       std::unique_ptr<ByteBuffer> pBuf;
+       std::unique_ptr<Bitmap> pBmp;
+       Dimension orgDim, tmpDim;
+       FloatDimension outDim;
+       BufferInfo bufInfo;
+
+       _ImageDecoder dec;
+
+       r = dec.Construct(srcImageBuf, _ImageUtilImpl::ToMediaPixelFormat(pixelFormat));
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
+
+       r = dec.GetDimension(orgDim.width, orgDim.height);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+       // Reset decoder output demension
+       dec.SetOutputDimension(_CoordinateSystemUtils::ConvertToInteger(destDim.width),
+                                                  _CoordinateSystemUtils::ConvertToInteger(destDim.height),
+                                                  true);
+
+       pBuf.reset(dec.DecodeN());
+       SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
+                          "[%s] Propagated", GetErrorMessage(GetLastResult()));
+
+       r = dec.GetDimension(tmpDim.width, tmpDim.height);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+       r = _ImageUtil::GetResizedDimension(orgDim.width, orgDim.height, destDim.width, destDim.height, outDim.width, outDim.height);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+       pBmp.reset(new (std::nothrow) Bitmap);
+       SysTryReturn(NID_MEDIA, pBmp.get() != null, null, E_OUT_OF_MEMORY,
+                          "[%s] new Bitmap", GetErrorMessage(GetLastResult()));
+
+       pBmp.reset(_BitmapImpl::GetNonScaledBitmapN(*pBuf.get(), tmpDim, pixelFormat));
+       SetLastResult(E_SUCCESS);
+       return pBmp.release();
+}
+
+Bitmap*
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat,
+                                                       const Tizen::Graphics::FloatDimension &destDim)
+{
+       std::unique_ptr<ByteBuffer> pBuf;
+       Bitmap* pBmp = null;
+
+       pBuf.reset(_MediaUtil::FileToBufferN(srcImagePath));
+       SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
+                          "[%s] FileToBufferN %S", GetErrorMessage(GetLastResult()), srcImagePath.GetPointer());
+
+       pBmp = DecodeToBitmapN(*pBuf.get(), pixelFormat, destDim);
+       return pBmp;
+}
+
 Tizen::Base::ByteBuffer*
 _ImageImpl::DecodeToBufferN(const Tizen::Base::String& srcImagePath,
                                                        Tizen::Graphics::Dimension &restDim,
index 83052d7..97ecff2 100644 (file)
@@ -103,8 +103,7 @@ _ImageUriDataEvent::FireImpl(Runtime::IEventListener& listener, const Runtime::I
                        std::unique_ptr<Bitmap> pBitmap(_ImageImpl::DecodeToBitmapN(*((pArg)->GetData()),
                                pArg->GetColorFormat(),
                                pArg->GetDestDimension(),
-                               BUFFER_SCALING_AUTO,
-                               pArg->GetImageFormat()));
+                               BUFFER_SCALING_AUTO));
 
                        if (pBitmap.get() != null)
                        {
diff --git a/src/inc/FMedia_ExifUtil.h b/src/inc/FMedia_ExifUtil.h
deleted file mode 100644 (file)
index 4074714..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-// Open Service Platform
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-#ifndef __FMEDIA_INTERNAL_EXIF_UTIL_H__
-#define __FMEDIA_INTERNAL_EXIF_UTIL_H__
-
-#include <FOspConfig.h>
-
-#define _EXIF_UTIL_LOG_ 1
-
-namespace Tizen { namespace Media
-{
-
-_OSP_EXPORT_ extern const wchar_t* const EXIF_TAG_IMAGE_ORIENTATION;
-_OSP_EXPORT_ extern const wchar_t* const EXIF_TAG_IMAGE_GPS_ALTITUDE;
-_OSP_EXPORT_ extern const wchar_t* const EXIF_TAG_IMAGE_GPS_LONGITUDE;
-_OSP_EXPORT_ extern const wchar_t* const EXIF_TAG_IMAGE_GPS_LATITUDE;
-
-class _OSP_EXPORT_ _ExifUtil
-       : public Tizen::Base::Object
-{
-public:
-       _ExifUtil();
-       ~_ExifUtil();
-
-       result Construct(const byte *buf, int length);
-       result GetValue(const Tizen::Base::String& key, int &value);
-       result GetValue(const Tizen::Base::String& key, double &value);
-
-protected:
-       void ForEachEntry(struct _ExifEntry *pEntry);
-       static void ForEachEntryStatic(struct _ExifEntry *pEntry, void *pUserData);
-
-       void ForEachContent(struct _ExifContent *pContent);
-       static void ForEachContentStatic(struct _ExifContent *pContent, void *pUserData);
-
-#if defined _EXIF_UTIL_LOG_
-//     static void ExifLogFuncStatic(ExifLog *log, ExifLogCode code, const char *domain, const char *format, va_list args, void *data);
-//     void ExifLogFunc(ExifLog *log, ExifLogCode code, const char *domain, const char *format, va_list args);
-#endif
-
-private:
-       struct _ExifData*__pExifData;
-       struct _ExifLog*__pExifLog;
-
-       short __orientation;
-       double __gpsLongitude;
-       double __gpsLatitude;
-       float __gpsAltitude;
-
-       bool __gpsLongitudeExist;
-       bool __gpsAltitudeExist;
-       bool __gpsLatitudeExist;
-       bool __orientationExist;
-};
-
-}}
-
-#endif
index ca6b61b..acecf30 100644 (file)
@@ -26,6 +26,7 @@
 #define _FMEDIA_INTERNAL_IMAGE_BUFFER_IMPL_H_
 
 #include <unique_ptr.h>
+#include <FMediaImageTypes.h>
 
 namespace Tizen { namespace Media
 {
@@ -85,6 +86,12 @@ public:
        */
        result Construct(const Tizen::Graphics::Bitmap &srcBitmap);
 
+       result Construct(const Tizen::Base::String &srcImagePath, int destWidth, int destHeight, ImageScalingMethod scalingMethod);
+
+       result Construct(const Tizen::Base::ByteBuffer &srcImageBuf, int destWidth, int destHeight, ImageScalingMethod scalingMethod);
+
+       ExifOrientation GetExifOrientation(void) const;
+
        /**
        * @see ImageBuffer::Equals()
        */
@@ -136,6 +143,11 @@ public:
        Tizen::Graphics::Bitmap* GetBitmapN(Tizen::Graphics::BitmapPixelFormat pixelFormat, Tizen::Graphics::BufferScaling bufferScaling) const;
 
        /**
+       * @see  ImageBuffer::GetBitmapN()
+       */
+       Tizen::Graphics::Bitmap* GetBitmapN(Tizen::Graphics::BitmapPixelFormat pixelFormat, const Tizen::Graphics::FloatDimension &destDim) const;
+
+       /**
        * @see  ImageBuffer::GetByteBufferN()
        */
        Tizen::Base::ByteBuffer* GetByteBufferN(MediaPixelFormat pixelFormat) const;
@@ -203,9 +215,11 @@ private:
        */
        _ImageBufferImpl& operator =(const _ImageBufferImpl& rhs);
 
-       std::unique_ptr<Tizen::Base::ByteBuffer> __pBuffer;
+       std::unique_ptr<byte[]> __pBuffer;
        int __width;
        int __height;
+       int __bufSize;
+       ExifOrientation __orientation;
        MediaPixelFormat __pixelFormat;
        bool __isLocked;
 };
index 455bb95..48ce65c 100644 (file)
@@ -54,11 +54,11 @@ public:
         * @see Image::DecodeToBitmapN()
         */
        static Tizen::Graphics::Bitmap*
-               DecodeToBitmapN(const Tizen::Base::String& srcImagePath,
-                                               Tizen::Graphics::BitmapPixelFormat pixelFormat = Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888,
-                                               const Tizen::Graphics::Dimension &desDim = Tizen::Graphics::Dimension(0, 0),
-                                               Tizen::Graphics::BufferScaling bufferScaling = Tizen::Graphics::BUFFER_SCALING_AUTO,
-                                               ImageFormat imgFormat = IMG_FORMAT_NONE, bool keepAspectRatio = true);
+               DecodeToBitmapN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat);
+
+       static Tizen::Graphics::Bitmap*
+               DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat);
+
        /**
         * Decodes an image data into the decoded bitmap container with resizing. @n
         * The currently supported decoding formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
@@ -66,12 +66,35 @@ public:
         *
         * @see Image::DecodeToBitmapN()
         */
-       static Tizen::Graphics::Bitmap*
+       /*static Tizen::Graphics::Bitmap*
                DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf,
                                                Tizen::Graphics::BitmapPixelFormat pixelFormat = Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888,
                                                const Tizen::Graphics::Dimension &dim = Tizen::Graphics::Dimension(0, 0),
                                                Tizen::Graphics::BufferScaling bufferScaling = Tizen::Graphics::BUFFER_SCALING_AUTO,
-                                               ImageFormat imgFormat = IMG_FORMAT_NONE, bool keepAspectRatio = true);
+                                               ImageFormat imgFormat = IMG_FORMAT_NONE, bool keepAspectRatio = true);*/
+
+       static Tizen::Graphics::Bitmap*
+               DecodeToBitmapN(const Tizen::Base::String& srcImagePath,
+                                               Tizen::Graphics::BitmapPixelFormat pixelFormat,
+                                               const Tizen::Graphics::Dimension &destDim,
+                                               Tizen::Graphics::BufferScaling bufferScaling = Tizen::Graphics::BUFFER_SCALING_AUTO);
+
+       static Tizen::Graphics::Bitmap*
+               DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf,
+                                               Tizen::Graphics::BitmapPixelFormat pixelFormat,
+                                               const Tizen::Graphics::Dimension &destDim,
+                                               Tizen::Graphics::BufferScaling bufferScaling = Tizen::Graphics::BUFFER_SCALING_AUTO);
+
+       static Tizen::Graphics::Bitmap*
+               DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf,
+                                               Tizen::Graphics::BitmapPixelFormat pixelFormat,
+                                               const Tizen::Graphics::FloatDimension &destDim);
+
+       static Tizen::Graphics::Bitmap*
+               DecodeToBitmapN(const Tizen::Base::String& srcImagePath,
+                                               Tizen::Graphics::BitmapPixelFormat pixelFormat,
+                                               const Tizen::Graphics::FloatDimension &destDim);
+
 
        /**
         * Decodes an image data into the decoded byte buffer container without resizing. @n