Nabi issue 45154 resolution
authorchitta ranjan <chitta.rs@samsung.com>
Thu, 11 Jul 2013 02:22:19 +0000 (11:22 +0900)
committerchitta ranjan <chitta.rs@samsung.com>
Thu, 11 Jul 2013 02:22:19 +0000 (11:22 +0900)
Change-Id: Ida48da350c3fcda221621c63663d7b12bdfe23a8
Signed-off-by: chitta ranjan <chitta.rs@samsung.com>
inc/MsgMessageComposePanel.h
src/MsgMessageComposePanel.cpp

index e5a238b..cfb9c9e 100644 (file)
@@ -169,6 +169,7 @@ private:
        AttachListPopup* __pAttachPopup;
        Tizen::Base::Runtime::Thread* __pWorkerThread;
        Tizen::Base::String __pSelectFilePath;
+       Tizen::Base::String __pOriginalFilePath;
        int __remainSizeBytes;
        int __defaultPageDuration;
        bool __isSendToEmailAddress;
index 4fe0de7..e9b29a5 100644 (file)
@@ -2386,6 +2386,10 @@ Object*
 MessageComposePanel::Run(void)
 {
        AppLogDebug("ENTER");
+       ExifOrientation imgOrientation;
+//     Tizen::Content::ImageMetadata*  pImageMeta = null;
+       ImageFormat imgFormat;
+       int height, width;
 
        MsgResponse status(MSG_RESPONSE_RESIZE_IMAGE);
        // Copy To MMS compose temp file.
@@ -2394,7 +2398,7 @@ MessageComposePanel::Run(void)
        mmsDataPath.Append(File::GetFileName(__pSelectFilePath));
        AppLogDebug("MMS DATA PATH: %S", mmsDataPath.GetPointer());
        result r = E_SUCCESS;
-       //__pOriginalFilePath = __pSelectFilePath;
+       __pOriginalFilePath = __pSelectFilePath;
        r = File::Copy(__pSelectFilePath, mmsDataPath, true);
        AppLogDebug("File to inserted copy result : %s ",GetErrorMessage(r));
        int i = 0;
@@ -2454,6 +2458,43 @@ MessageComposePanel::Run(void)
                status = MSG_RESPONSE_FAIL;
        }
 
+
+       if (__pSelectFilePath.EndsWith(L".jpg") ||      __pSelectFilePath.EndsWith(L".jpeg"))
+       {
+               ImageBuffer::GetImageInfo(__pSelectFilePath, imgFormat, width, height);
+               ImageBuffer* pImageBuffer = new (std::nothrow) ImageBuffer();
+               r = pImageBuffer->Construct(__pSelectFilePath);
+               ImageBuffer* pOriginalImageBuffer = new (std::nothrow) ImageBuffer();
+               r = pOriginalImageBuffer->Construct(__pOriginalFilePath, width, height, IMAGE_SCALING_METHOD_FAST_BILINEAR );//Construct(__pOriginalFilePath);
+
+               if (pOriginalImageBuffer && pImageBuffer)
+               {
+                       imgOrientation = pOriginalImageBuffer->GetExifOrientation();
+                       AppLog("ExifOrientation = %d", pOriginalImageBuffer->GetExifOrientation());
+
+                       if (imgOrientation == EXIF_ORIENTATION_RIGHT_TOP ||
+                                       imgOrientation == EXIF_ORIENTATION_TOP_RIGHT )
+                       {
+                               pImageBuffer = pImageBuffer->RotateN(IMAGE_ROTATION_90);
+                               r = pImageBuffer->EncodeToFile(__pSelectFilePath, IMG_FORMAT_JPG, true, 70);
+                       }
+                       else if (imgOrientation == EXIF_ORIENTATION_RIGHT_BOTTOM ||
+                                       imgOrientation == EXIF_ORIENTATION_BOTTOM_RIGHT)
+                       {
+                               pImageBuffer = pImageBuffer->RotateN(IMAGE_ROTATION_180);
+                               r = pImageBuffer->EncodeToFile(__pSelectFilePath, IMG_FORMAT_JPG, true, 70);
+                       }
+                       else if (imgOrientation == EXIF_ORIENTATION_LEFT_BOTTOM ||
+                                       imgOrientation  == EXIF_ORIENTATION_BOTTOM_LEFT)
+                       {
+                               pImageBuffer = pImageBuffer->RotateN(IMAGE_ROTATION_270);
+                               r = pImageBuffer->EncodeToFile(__pSelectFilePath, IMG_FORMAT_JPG, true, 70);
+                       }
+                       delete pImageBuffer;
+                       delete pOriginalImageBuffer;
+               }
+       }
+
        // Send event to main thread from worker thread.
        ArrayList* pArgList = new ArrayList();
        pArgList->Construct();