N_SE-53617
authorabhismita ghosh <g.abhismita@samsung.com>
Fri, 4 Oct 2013 13:51:29 +0000 (19:21 +0530)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Tue, 8 Oct 2013 01:10:30 +0000 (01:10 +0000)
Change-Id: I4100b19286fe16c5cbe4148ddc745d7f7509e1dc

inc/GlImageCropForm.h [new file with mode: 0644]
inc/GlTypes.h
res/screen-density-xhigh/T01-1_crop_rectangle.png [new file with mode: 0644]
res/screen-size-normal/IDL_FORM_IMAGE_CROP.xml [new file with mode: 0644]
src/GlAlbumListForm.cpp
src/GlFormFactory.cpp
src/GlImageCropForm.cpp [new file with mode: 0644]
src/GlImageListEditorPanel.cpp
src/GlMainFrame.cpp
src/GlTypes.cpp

diff --git a/inc/GlImageCropForm.h b/inc/GlImageCropForm.h
new file mode 100644 (file)
index 0000000..726998e
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// 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.
+//
+
+/**
+ * @file               GlImageCropForm.h
+ * @brief              This is the implementation file for Image Crop.
+ */
+
+#ifndef _GL_IMAGE_CROP_H_
+#define _GL_IMAGE_CROP_H_
+
+#include <FMedia.h>
+#include <FUi.h>
+
+enum TouchLocation
+{
+       INSIDE_CROPBOX = 0,
+       OUTSIDE_CROPBOX,
+       INSIDE_TOP_RECTANGLE,
+       INSIDE_BOTTOM_RECTANGLE,
+       INSIDE_LEFT_RECTANGLE,
+       INSIDE_RIGHT_RECTANGLE,
+       INSIDE_TOP_LEFT_RECTANGLE,
+       INSIDE_TOP_RIGHT_RECTANGLE,
+       INSIDE_BOTTOM_LEFT_RECTANGLE,
+       INSIDE_BOTTOM_RIGHT_RECTANGLE,
+};
+
+class ImageCropForm
+       : public Tizen::Ui::Controls::Form
+       , public Tizen::Ui::Controls::IFormBackEventListener
+       , public Tizen::Ui::IActionEventListener
+       , public Tizen::Ui::IOrientationEventListener
+       , public Tizen::Ui::ITouchEventListener
+       , public Tizen::Ui::Scenes::ISceneEventListener
+{
+public:
+       ImageCropForm(void);
+       ~ImageCropForm(void);
+
+       bool Initialize(void);
+       void CheckCurrentPosition(const Tizen::Graphics::Point currentPosition);
+       void SetValue(void);
+       Tizen::Base::String GetFileName(const Tizen::Base::String& filePath, bool isCheckExe = false) const;
+
+       virtual result OnInitializing(void);
+       virtual result OnDraw(void);
+
+       virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
+
+       virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+
+       virtual void OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus);
+
+       virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
+       virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
+       virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
+       virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
+       virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
+
+       virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
+       virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId);
+
+private:
+       Tizen::Base::String __sourceFilePath;
+       Tizen::Base::String __cropMode;
+       Tizen::Graphics::Canvas* __pCanvas;
+       Tizen::Graphics::Bitmap* __pCurrentBitmap;
+       Tizen::Graphics::Bitmap* __pRectangleBitmap;
+       Tizen::Graphics::Point __touchStart;
+       Tizen::Graphics::Rectangle __cropBox;
+       Tizen::Graphics::Rectangle __imageBox;
+       Tizen::Media::ImageBuffer __imageBuffer;
+       Tizen::Media::ImageFormat __imageFormat;
+       TouchLocation __pointLocation;
+       bool __isOrientationChanged;
+       int __imageHeight;
+       int __imageWidth;
+       int __statusValue;
+       int __formHeight;
+       int __formWidth;
+       int __skipMoveEvent;
+};
+
+#endif /* _GL_IMAGE_CROP_H_ */
index 3ac1ee0..8a52c55 100644 (file)
@@ -31,6 +31,7 @@ enum ACTION_ID_
        IDA_BUTTON_CREATE_NAME_SAVE = 103,
        IDA_BUTTON_MOVE_TO_SELECTION = 104,
        IDA_BUTTON_UNCHECKED = 105,
+       IDA_BUTTON_SAVE = 106,
        IDA_ALBUM_LIST_SELECT_ALL = 201,
        IDA_FILE_LIST_SELECT_ALL = 202,
        IDA_CONTEXT_MENU_MESSAGE = 301,
@@ -150,6 +151,7 @@ extern const wchar_t* IDL_FORM_FILE_LIST;
 extern const wchar_t* IDL_FORM_SETTING_MAIN;
 extern const wchar_t* IDL_FORM_SETTING_INTERVAL;
 extern const wchar_t* IDL_FORM_SETTING_TRANSITION;
+extern const wchar_t* IDL_FORM_IMAGE_CROP;
 
 extern const wchar_t* IDC_LABEL_ALBUM_LIST_EDITOR_SELECTED;
 
@@ -161,6 +163,7 @@ extern const wchar_t* IDC_FORM_FILE_LIST_EDITOR;
 extern const wchar_t* IDC_FORM_SETTING_MAIN;
 extern const wchar_t* IDC_FORM_SETTING_INTERVAL;
 extern const wchar_t* IDC_FORM_SETTING_TRANSITION;
+extern const wchar_t* IDC_FORM_IMAGE_CROP;
 
 extern const wchar_t* IDC_PANEL_BLANK;
 extern const wchar_t* IDC_PANEL_ALL_LIST;
@@ -184,6 +187,7 @@ extern const wchar_t* IDSCN_ALL_LIST_SELECTION;
 extern const wchar_t* IDSCN_SETTING_MAIN;
 extern const wchar_t* IDSCN_SETTING_INTERVAL;
 extern const wchar_t* IDSCN_SETTING_TRANSITION;
+extern const wchar_t* IDSCN_IMAGE_CROP;
 
 extern const wchar_t* APPCONTROL_PROVIDER_ID_CAMERA;
 extern const wchar_t* APPCONTROL_PROVIDER_ID_MESSAGE;
@@ -205,6 +209,7 @@ extern const wchar_t* APPCONTROL_KEY_SELECTION_MODE;
 extern const wchar_t* APPCONTROL_KEY_DATA_SELECTED;
 extern const wchar_t* APPCONTROL_KEY_MESSAGE_TYPE;
 extern const wchar_t* APPCONTROL_KEY_CAMERA_ALLOW_SWITCH;
+extern const wchar_t* APPCONTROL_KEY_IMAGEVIEWER_MODE;
 
 extern const wchar_t* APPCONTROL_URI_MMS_TO;
 extern const wchar_t* APPCONTROL_URI_MAIL_TO;
@@ -220,6 +225,8 @@ extern const wchar_t* APPCONTROL_DATA_SLIDE_SHOW;
 extern const wchar_t* APPCONTROL_DATA_SELECTION_MODE;
 extern const wchar_t* APPCONTROL_DATA_TRUE;
 extern const wchar_t* APPCONTROL_DATA_MMS;
+extern const wchar_t* APPCONTROL_DATA_CROP_TYPE_AUTO;
+extern const wchar_t* APPCONTROL_DATA_CROP_TYPE_FIT_TO_SCREEN;
 
 extern const wchar_t* APPCONTROL_RESULT_KEY_LEGACY_RESULT;
 
@@ -330,6 +337,8 @@ extern const wchar_t* IDB_ALBUM_RENAME_PROGRESS30;
 extern const wchar_t* IDB_IMAGE_CONTEXT_EMAIL_ICON;
 extern const wchar_t* IDB_IMAGE_CONTEXT_MESSAGE_ICON;
 
+extern const wchar_t* IDB_IMAGE_CROP_RECTANGLE;
+
 static const unsigned int CUSTOM_COLOR_GREY = Tizen::Graphics::Color32<124,124,124>::Value;
 static const unsigned int CUSTOM_COLOR_TRANSPARENT = Tizen::Graphics::Color32<0,0,0>::Value;
 static const unsigned int CUSTOM_BACKGROUND_COLOR_LISTVIEW = Tizen::Graphics::Color32<236,240,242>::Value;
diff --git a/res/screen-density-xhigh/T01-1_crop_rectangle.png b/res/screen-density-xhigh/T01-1_crop_rectangle.png
new file mode 100644 (file)
index 0000000..6e89c37
Binary files /dev/null and b/res/screen-density-xhigh/T01-1_crop_rectangle.png differ
diff --git a/res/screen-size-normal/IDL_FORM_IMAGE_CROP.xml b/res/screen-size-normal/IDL_FORM_IMAGE_CROP.xml
new file mode 100644 (file)
index 0000000..ff005c6
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+       This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<!DOCTYPE Scene SYSTEM "UIForm.dtd">
+
+<Scene Bversion="2.0.0.201306151404" Dversion="20120315">
+    <LogicalCoordinate>720</LogicalCoordinate>
+    <Form id="IDL_FORM_IMAGE_CROP">
+        <property backgroundColor="" backgroundColorOpacity="100" notificationTrayOpenEnabled="false" orientation="Automatic" softKey0NormalIcon="" softKey0PressedIcon="" softKey0Text="" softKey1NormalIcon="" softKey1PressedIcon="" softKey1Text="" title="" titleAlign="ALIGN_CENTER" titleIcon="" translucentFooter="false" translucentHeader="false" translucentIndicator="false"/>
+        <layout mode="Portrait" style="FORM_STYLE_FOOTER|FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE|FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE" type="LAYOUT_RELATIVE"/>
+        <layout mode="Landscape" style="FORM_STYLE_FOOTER|FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE|FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE" type="LAYOUT_RELATIVE"/>
+    </Form>
+    <Footer>
+        <property backgroundBitmapPath="" color="" colorOpacity="100" disabledButtonColor="" disabledButtonColorOpacity="100" disabledButtonTextColor="" disabledItemColor="" disabledItemColorOpacity="100" disabledItemTextColor="" footerStyle="FOOTER_STYLE_TAB" highlightedButtonColor="" highlightedButtonColorOpacity="100" highlightedButtonTextColor="" highlightedItemColor="" highlightedItemColorOpacity="100" highlightedItemTextColor="" normalButtonColor="" normalButtonColorOpacity="100" normalButtonTextColor="" normalItemColor="" normalItemColorOpacity="100" normalItemTextColor="" pressedButtonColor="" pressedButtonColorOpacity="100" pressedButtonTextColor="" pressedItemColor="" pressedItemColorOpacity="100" pressedItemTextColor="" selectedItemColor="" selectedItemColorOpacity="100" selectedItemTextColor="" showBackButton="false" showMenuButton="false"/>
+        <itemSet/>
+    </Footer>
+</Scene>
index 1e09917..a99911d 100644 (file)
@@ -371,14 +371,10 @@ AlbumListForm::OnFormBackRequested(Form& source)
        AppLogDebug("ENTER");
        if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
        {
-               AppLogDebug("APP_CONTROL_MODE_PICK");
                GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
                if (pApp != null && pApp->GetFrameActivated() == true)
                {
-                       if (__pPresentationModel->GetAppControlMode() == APPCONTROL_MODE_PICK)
-                       {
-                               pApp->SendAppControlResult(APP_CTRL_RESULT_CANCELED, null);
-                       }
+                       pApp->SendAppControlResult(APP_CTRL_RESULT_CANCELED, null);
                        pApp->Terminate();
                }
        }
index 9068f44..f4161f2 100644 (file)
@@ -25,6 +25,7 @@
 #include "GlFileListEditorForm.h"
 #include "GlFileListForm.h"
 #include "GlFormFactory.h"
+#include "GlImageCropForm.h"
 #include "GlSettingMainForm.h"
 #include "GlTypes.h"
 
@@ -94,6 +95,13 @@ FormFactory::CreateFormN(const String& formId, const SceneId& sceneId)
                pSceneManager->AddSceneEventListener(sceneId, *pForm);
                pNewForm = pForm;
        }
+       else if (formId == IDC_FORM_IMAGE_CROP)
+       {
+               ImageCropForm* pForm = new (std::nothrow) ImageCropForm();
+               pForm->Initialize();
+               pSceneManager->AddSceneEventListener(sceneId, *pForm);
+               pNewForm = pForm;
+       }
 
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
diff --git a/src/GlImageCropForm.cpp b/src/GlImageCropForm.cpp
new file mode 100644 (file)
index 0000000..ab7e4ce
--- /dev/null
@@ -0,0 +1,935 @@
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// 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.
+//
+
+/**
+ * @file               GlImageCrop.cpp
+ * @brief              This is the implementation file for Image Crop.
+ */
+
+#include <FApp.h>
+#include <FMedia.h>
+#include <FSystem.h>
+#include <FText.h>
+#include "GlGalleryApp.h"
+#include "GlImageCropForm.h"
+#include "GlResourceManager.h"
+#include "GlTypes.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Content;
+using namespace Tizen::Graphics;
+using namespace Tizen::Io;
+using namespace Tizen::Media;
+using namespace Tizen::System;
+using namespace Tizen::Text;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+static const unsigned int COLOR_GALLERY_BG = Color32<31,31,31>::Value;
+static const unsigned int CROP_BOX_RECTANGLE_COLOR = Color32<199, 110, 6>::Value;
+static const int CROP_BOX_LINE_WIDTH = 5;
+static const int H_CROP_RECTANGLE = 20;
+static const wchar_t* PATH_DATA_DIRECTORY_IN_CROP = L"data/";
+static const wchar_t* FILE_NAME_SEPARATOR = L"_";
+static const int MAX_FILE_LENGHT = 255;
+static const int CROP_BOX_OFFSET = 20;
+
+ImageCropForm::ImageCropForm(void)
+       : __sourceFilePath(L"")
+       , __cropMode(APPCONTROL_DATA_CROP_TYPE_FIT_TO_SCREEN)
+       , __pCanvas(null)
+    , __pCurrentBitmap(null)
+       , __pRectangleBitmap(null)
+       , __imageFormat(IMG_FORMAT_NONE)
+       , __pointLocation(OUTSIDE_CROPBOX)
+       , __isOrientationChanged(false)
+       , __imageHeight(0)
+       , __imageWidth(0)
+       , __statusValue(-1)
+       , __formHeight(0)
+       , __formWidth(0)
+       , __skipMoveEvent(0)
+{
+}
+
+ImageCropForm::~ImageCropForm(void)
+{
+       if (__pCurrentBitmap != null)
+       {
+               delete __pCurrentBitmap;
+       }
+       if (__pRectangleBitmap != null)
+       {
+               delete __pRectangleBitmap;
+       }
+       if (__pCanvas != null)
+       {
+               delete __pCanvas;
+       }
+}
+
+bool
+ImageCropForm::Initialize(void)
+{
+       Form::Construct(IDL_FORM_IMAGE_CROP);
+
+       return true;
+}
+
+result
+ImageCropForm::OnInitializing(void)
+{
+       AppLogDebug("OnInitializing");
+
+       AppResource* pAppResource = null;
+       pAppResource = UiApp::App::GetInstance()->GetAppResource();
+
+       if (pAppResource != null)
+       {
+               __pRectangleBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_RECTANGLE);
+       }
+
+       Footer* pFooter = GetFooter();
+       if (pFooter != null)
+       {
+               pFooter->AddActionEventListener(*this);
+               pFooter->RemoveAllItems();
+               pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
+
+               FooterItem footerItem1;
+               footerItem1.Construct(IDA_BUTTON_SAVE);
+               footerItem1.SetText(ResourceManager::GetString(L"IDS_COM_OPT_SAVE"));
+
+               pFooter->AddItem(footerItem1);
+       }
+
+       AddTouchEventListener(*this);
+       AddOrientationEventListener(*this);
+       SetFormBackEventListener(this);
+
+       return E_SUCCESS;
+}
+
+result
+ImageCropForm::OnDraw(void)
+{
+       AppLogDebug("OnDraw");
+       result r = E_SUCCESS;
+
+       if (__pCanvas != null)
+       {
+               __pCanvas->Clear();
+               r = __pCanvas->SetLineWidth(CROP_BOX_LINE_WIDTH);
+               r = __pCanvas->DrawBitmap(Rectangle(__imageBox.x, __imageBox.y, __imageBox.width, __imageBox.height), *__pCurrentBitmap); // Image to be cropped
+               r = __pCanvas->DrawRectangle(Rectangle(__cropBox.x, __cropBox.y, __cropBox.width, __cropBox.height)); // Cropbox rectangle
+               r = __pCanvas->DrawBitmap(Rectangle((__cropBox.x + __cropBox.width / 2) - (H_CROP_RECTANGLE / 2), __cropBox.y - (H_CROP_RECTANGLE / 2), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Top Rectangle
+               r = __pCanvas->DrawBitmap(Rectangle((__cropBox.x + __cropBox.width / 2) - (H_CROP_RECTANGLE / 2), (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2)), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Bottom Rectangle
+               r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (H_CROP_RECTANGLE / 2), (__cropBox.y + __cropBox.height / 2) - (H_CROP_RECTANGLE / 2), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); //Left Rectangle
+               r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (H_CROP_RECTANGLE / 2), (__cropBox.y + __cropBox.height / 2) - (H_CROP_RECTANGLE / 2), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); //Right Rectangle
+               r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (H_CROP_RECTANGLE / 2), __cropBox.y - (H_CROP_RECTANGLE / 2), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Top Left Rectangle
+               r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (H_CROP_RECTANGLE / 2), __cropBox.y - (H_CROP_RECTANGLE / 2), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Top Right Rectangle
+               r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (H_CROP_RECTANGLE / 2), (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2)), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Bottom Right Rectangle
+               r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (H_CROP_RECTANGLE / 2), (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2)), H_CROP_RECTANGLE, H_CROP_RECTANGLE), *__pRectangleBitmap); // Bottom Left Rectangle
+               __pCanvas->SetBackgroundColor(COLOR_GALLERY_BG);
+       }
+
+       return r;
+}
+
+void
+ImageCropForm::OnFormBackRequested(Form& source)
+{
+       AppLogDebug("OnFormBackRequested");
+
+       SceneManager::GetInstance()->GoBackward(BackwardSceneTransition());
+}
+
+void
+ImageCropForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+       AppLogDebug("OnActionPerformed");
+       result r = E_SUCCESS;
+
+       switch(actionId)
+       {
+       case IDA_BUTTON_SAVE:
+       {
+               GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
+
+               if (pApp != null && pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_PICK)
+               {
+                       ImageBuffer* pCropBuffer = null;
+                       int count = 1;
+                       int index = 0;
+
+                       String destFilePath;
+                       destFilePath.Append(App::GetInstance()->GetAppSharedPath());
+                       destFilePath.Append(PATH_DATA_DIRECTORY_IN_CROP);
+                       destFilePath.Append(GetFileName(__sourceFilePath));
+                       destFilePath.Reverse();
+                       r = destFilePath.IndexOf(FILE_EXT_SEPARATOR, 0, index);
+                       destFilePath.Reverse();
+                       if (r != E_SUCCESS)
+                       {
+                               index = 0;
+                               destFilePath.Append(FILE_EXT_SEPARATOR);
+                       }
+                       destFilePath.Insert(FILE_NAME_SEPARATOR, destFilePath.GetLength() - index - 1);
+                       destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
+
+                       if (__imageFormat != IMG_FORMAT_JPG || __imageFormat != IMG_FORMAT_PNG || __imageFormat != IMG_FORMAT_BMP)
+                       {
+                               destFilePath.Remove(destFilePath.GetLength() - index, index);
+                               destFilePath.Append(CONTENT_EXT_JPG);
+                       }
+
+                       while (File::IsFileExist(destFilePath) == true)
+                       {
+                               count++;
+                               destFilePath.Clear();
+                               destFilePath.Append(App::GetInstance()->GetAppSharedPath());
+                               destFilePath.Append(PATH_DATA_DIRECTORY_IN_CROP);
+                               destFilePath.Append(GetFileName(__sourceFilePath));
+                               destFilePath.Insert(FILE_NAME_SEPARATOR, destFilePath.GetLength() - index - 1);
+                               destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
+                               if (__imageFormat != IMG_FORMAT_JPG || __imageFormat != IMG_FORMAT_PNG || __imageFormat != IMG_FORMAT_BMP)
+                               {
+                                       destFilePath.Remove(destFilePath.GetLength() - index, index);
+                                       destFilePath.Append(CONTENT_EXT_JPG);
+                               }
+                       }
+
+                       AppCtrlResult appControlResult = APP_CTRL_RESULT_FAILED;
+                       HashMap* pMap = null;
+                       int inputLength = 0;
+                       Utf8Encoding utf8;
+                       r = utf8.GetByteCount(GetFileName(destFilePath), inputLength);
+
+                       while (inputLength > MAX_FILE_LENGHT)
+                       {
+                               destFilePath.IndexOf(FILE_NAME_SEPARATOR, 0, index);
+                               destFilePath.Remove(index - 1, 1);
+                               r = utf8.GetByteCount(GetFileName(destFilePath), inputLength);
+                       }
+
+                       pCropBuffer = __imageBuffer.CropN(((__cropBox.x - __imageBox.x) * __imageWidth) / __imageBox.width, ((__cropBox.y - __imageBox.y) * __imageHeight) / __imageBox.height,
+                                               (__cropBox.width * __imageWidth) / __imageBox.width, (__cropBox.height * __imageHeight) / __imageBox.height);
+
+                       if (pCropBuffer != null)
+                       {
+                               if (__imageFormat == IMG_FORMAT_JPG || __imageFormat == IMG_FORMAT_PNG || __imageFormat == IMG_FORMAT_BMP)
+                               {
+                                       r = pCropBuffer->EncodeToFile(destFilePath, __imageFormat, true, 100);
+                               }
+                               else
+                               {
+                                       r = pCropBuffer->EncodeToFile(destFilePath, IMG_FORMAT_JPG, true, 100);
+                               }
+                               delete pCropBuffer;
+
+                               if (r == E_SUCCESS )
+                               {
+                                       ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+                                       pList->Add(new (std::nothrow) String(destFilePath));
+
+                                       pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
+                                       pMap->Construct();
+                                       pMap->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), pList);
+
+                                       appControlResult = APP_CTRL_RESULT_SUCCEEDED;
+                               }
+                               else
+                               {
+                                       appControlResult = APP_CTRL_RESULT_FAILED;
+                               }
+                       }
+                       else
+                       {
+                               appControlResult = APP_CTRL_RESULT_FAILED;
+                       }
+
+                       pApp->SendAppControlResult(appControlResult, pMap);
+                       pApp->Terminate();
+               }
+       }
+       break;
+       }
+
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+       return;
+}
+
+void
+ImageCropForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
+{
+       AppLogDebug("OnOrientationChanged");
+
+       __isOrientationChanged = true;
+       SetValue();
+
+       if (__pCanvas != null)
+       {
+               __pCanvas->Clear();
+       }
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+void
+ImageCropForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+       AppLogDebug("OnTouchPressed");
+
+       __touchStart = currentPosition;
+       CheckCurrentPosition(currentPosition);
+
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+void
+ImageCropForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+       if (++__skipMoveEvent % 5 != 0)
+       {
+               return;
+       }
+       else
+       {
+               __skipMoveEvent = 0;
+       }
+
+       int deltaX = currentPosition.x - __touchStart.x;
+       int deltaY = currentPosition.y - __touchStart.y;
+       if (__cropMode.Equals(APPCONTROL_DATA_CROP_TYPE_AUTO, false))
+       {
+               switch(__pointLocation)
+               {
+               case INSIDE_TOP_RECTANGLE:
+               {
+                       if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (H_CROP_RECTANGLE * 3)))
+                       {
+                               __cropBox.y += deltaY;
+                               __cropBox.height -= deltaY;
+                       }
+               }
+               break;
+
+               case INSIDE_BOTTOM_RECTANGLE:
+               {
+                       if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height)
+                               && (__cropBox.height + deltaY) > (H_CROP_RECTANGLE * 3))
+                       {
+                               __cropBox.height += deltaY;
+                       }
+               }
+               break;
+
+               case INSIDE_LEFT_RECTANGLE:
+               {
+                       if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (H_CROP_RECTANGLE * 3))
+                       {
+                               __cropBox.x += deltaX;
+                               __cropBox.width -= deltaX;
+                       }
+               }
+               break;
+
+               case INSIDE_RIGHT_RECTANGLE:
+               {
+                       if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width)
+                               && __cropBox.width + deltaX > (H_CROP_RECTANGLE * 3))
+                       {
+                               __cropBox.width += deltaX;
+                       }
+               }
+               break;
+
+               case INSIDE_TOP_LEFT_RECTANGLE:
+               {
+                       if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (H_CROP_RECTANGLE * 3))
+                                       && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (H_CROP_RECTANGLE * 3))
+                       {
+                               __cropBox.y += deltaY;
+                               __cropBox.height -= deltaY;
+                               __cropBox.x += deltaX;
+                               __cropBox.width -= deltaX;
+                       }
+               }
+               break;
+
+               case INSIDE_TOP_RIGHT_RECTANGLE:
+               {
+                       if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (H_CROP_RECTANGLE * 3))
+                                       && (__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (H_CROP_RECTANGLE * 3))
+                       {
+                               __cropBox.width += deltaX;
+                               __cropBox.y += deltaY;
+                               __cropBox.height -= deltaY;
+                       }
+               }
+               break;
+
+               case INSIDE_BOTTOM_LEFT_RECTANGLE:
+               {
+                       if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (H_CROP_RECTANGLE * 3)
+                               && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (H_CROP_RECTANGLE * 3))
+                       {
+                               __cropBox.x += deltaX;
+                               __cropBox.width -= deltaX;
+                               __cropBox.height += deltaY;
+                       }
+               }
+               break;
+
+               case INSIDE_BOTTOM_RIGHT_RECTANGLE:
+               {
+                       if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (H_CROP_RECTANGLE * 3)
+                               && (__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (H_CROP_RECTANGLE * 3))
+                       {
+                               __cropBox.width += deltaX;
+                               __cropBox.height += deltaY;
+                       }
+               }
+               break;
+
+               case INSIDE_CROPBOX:
+               {
+                       if ((__cropBox.x + deltaX) > __imageBox.x)
+                       {
+                               __cropBox.x += deltaX;
+                       }
+                       else
+                       {
+                               __cropBox.x = __imageBox.x;
+                       }
+                       if ((__cropBox.y + deltaY) > __imageBox.y)
+                       {
+                               __cropBox.y += deltaY;
+                       }
+                       else
+                       {
+                               __cropBox.y = __imageBox.y;
+                       }
+                       if ((__cropBox.x + __cropBox.width + deltaX) > (__imageBox.x + __imageBox.width))
+                       {
+                               __cropBox.x = __imageBox.x + __imageBox.width - __cropBox.width;
+                       }
+                       if ((__cropBox.y + __cropBox.height + deltaY) > (__imageBox.y + __imageBox.height))
+                       {
+                               __cropBox.y = __imageBox.y + __imageBox.height - __cropBox.height;
+                       }
+               }
+               break;
+
+               default:
+                       break;
+               }
+       }
+       else if (__cropMode.Equals(APPCONTROL_DATA_CROP_TYPE_FIT_TO_SCREEN, false))
+       {
+               if (__pointLocation == INSIDE_LEFT_RECTANGLE || __pointLocation == INSIDE_BOTTOM_LEFT_RECTANGLE
+                       || __pointLocation == INSIDE_TOP_LEFT_RECTANGLE)
+               {
+                       int temp = __cropBox.height;
+                       int height = (__formHeight * (__cropBox.width - (2 * deltaX))) /__formWidth;
+                       temp = height - temp;
+                       if ((__cropBox.width - (2 * deltaX) > (H_CROP_RECTANGLE * 3)) && (!(height >= __imageBox.height || (__cropBox.width - (2 * deltaX)) >= __imageBox.width)))
+                       {
+                               if (__cropBox.x + deltaX >= __imageBox.x && __cropBox.x + __cropBox.width - deltaX <= __imageBox.x + __imageBox.width
+                                       && __cropBox.y - (temp / 2) >= __imageBox.y && __cropBox.y + __cropBox.height + (temp / 2) < __imageBox.y + __imageBox.height
+                                       && (__cropBox.width - (2 * deltaX) > (H_CROP_RECTANGLE * 3)))
+                               {
+                                       __cropBox.x += deltaX;
+                                       __cropBox.width = __cropBox.width - (2 * deltaX);
+                                       __cropBox.height = height;
+                                       __cropBox.y = __cropBox.y - (temp / 2);
+                               }
+                               else if ((__cropBox.y + __cropBox.height) <= (__imageBox.y + __imageBox.height)
+                                               && __cropBox.width < __imageBox.width
+                                               && __cropBox.x + deltaX >= __imageBox.x && __cropBox.y - temp >= __imageBox.y )
+                               {
+                                       if (__cropBox.x + __cropBox.width - deltaX <= __imageBox.x + __imageBox.width
+                                               && __cropBox.x + deltaX >= __imageBox.x)
+                                       {
+                                               __cropBox.x += deltaX;
+                                       }
+                                       else
+                                       {
+                                               __cropBox.x = __cropBox.x + (2 * deltaX);
+                                       }
+                                       __cropBox.width = __cropBox.width - (2 * deltaX);
+                                       __cropBox.height = height;
+                                       __cropBox.y = __cropBox.y - temp;
+                               }
+                               else if (__cropBox.y - (temp / 2) <= __imageBox.y && __cropBox.width - (deltaX) <= __imageBox.width
+                                               && __cropBox.x + deltaX >= __imageBox.x && __cropBox.y + __cropBox.height + temp <= __imageBox.y + __imageBox.height)
+                               {
+                                       if (__cropBox.x + __cropBox.width - deltaX <= __imageBox.x + __imageBox.width)
+                                       {
+                                               __cropBox.x += deltaX;
+                                       }
+                                       else
+                                       {
+                                               __cropBox.x = __cropBox.x + (2 * deltaX);
+                                       }
+                                       __cropBox.width = __cropBox.width - (2 * deltaX);
+                                       __cropBox.height = height;
+                               }
+                       }
+               }
+               else if (__pointLocation == INSIDE_RIGHT_RECTANGLE || __pointLocation == INSIDE_BOTTOM_RIGHT_RECTANGLE
+                               || __pointLocation == INSIDE_TOP_RIGHT_RECTANGLE)
+               {
+                       deltaX *= -1;
+                       int temp = __cropBox.height;
+                       int height = (__formHeight * (__cropBox.width - (2 * deltaX))) / __formWidth;
+                       temp = height - temp;
+                       if ((__cropBox.width - (2 * deltaX) > (H_CROP_RECTANGLE * 3)) && (!(height >= __imageBox.height || (__cropBox.width - (2 * deltaX)) >= __imageBox.width)))
+                       {
+                               if (deltaX < __cropBox.width - (H_CROP_RECTANGLE * 3))
+                               {
+                                       if (__cropBox.x + deltaX > __imageBox.x && __cropBox.x + __cropBox.width - deltaX <= __imageBox.x + __imageBox.width
+                                               && __cropBox.y - (temp / 2) > __imageBox.y && __cropBox.y + __cropBox.height + (temp / 2) < __imageBox.y + __imageBox.height)
+                                       {
+                                               __cropBox.x += deltaX;
+                                               __cropBox.width = __cropBox.width - (2 * deltaX);;
+                                               __cropBox.height = height;
+                                               __cropBox.y = __cropBox.y - (temp / 2);
+                                       }
+                                       else if ((__cropBox.y + __cropBox.height + (temp / 2)) >= (__imageBox.y + __imageBox.height)
+                                                       && __cropBox.x + __cropBox.width - (2 * deltaX) <= __imageBox.x + __imageBox.width
+                                                       && __cropBox.x - deltaX >= __imageBox.x && __cropBox.y - temp >= __imageBox.y )
+                                       {
+                                               if (__cropBox.x + __cropBox.width - deltaX <= __imageBox.x + __imageBox.width
+                                                       && __cropBox.x + deltaX >= __imageBox.x)
+                                               {
+                                                       __cropBox.x += deltaX;
+                                               }
+                                               __cropBox.width = __cropBox.width - (2 * deltaX);
+                                               __cropBox.height = height;
+                                               __cropBox.y = __cropBox.y - temp;
+                                       }
+                                       else if (__cropBox.y - (temp / 2) <= __imageBox.y && __cropBox.width - (deltaX) <= __imageBox.width
+                                                       && __cropBox.x + deltaX <= __imageBox.x && __cropBox.y + __cropBox.height + temp <= __imageBox.y + __imageBox.height)
+                                       {
+                                               if (__cropBox.x + deltaX >= __imageBox.x)
+                                               {
+                                                       __cropBox.x += deltaX;
+                                               }
+                                               else
+                                               {
+                                                       __cropBox.x = __imageBox.x;
+                                               }
+                                               __cropBox.width = __cropBox.width - (2 * deltaX);
+                                               __cropBox.height = height;
+                                       }
+                                       else if (__cropBox.y - (temp / 2) <= __imageBox.y && __cropBox.x + deltaX >= __imageBox.x
+                                                       && __cropBox.x + __cropBox.width - deltaX <= __imageBox.x + __imageBox.width
+                                                       && __cropBox.y + __cropBox.height + temp <= __imageBox.y + __imageBox.height)
+                                       {
+                                               __cropBox.x += deltaX;
+                                               __cropBox.width = __cropBox.width - (2 * deltaX);
+                                               __cropBox.height = height;
+                                       }
+                                       else if (__cropBox.x + deltaX <= __imageBox.x && __cropBox.y - (temp / 2) >= __imageBox.y
+                                                       && __cropBox.x + __cropBox.width - (2 * deltaX) <= __imageBox.x + __imageBox.width
+                                                       && __cropBox.y + __cropBox.height + temp <= __imageBox.y + __imageBox.height)
+                                       {
+                                               __cropBox.width = __cropBox.width - (2 * deltaX);
+                                               __cropBox.y = __cropBox.y - (temp / 2);
+                                               __cropBox.height = height;
+                                       }
+                               }
+                       }
+               }
+               else if (__pointLocation == INSIDE_TOP_RECTANGLE)
+               {
+                       int temp = __cropBox.width;
+                       int width = (__formWidth * (__cropBox.height - (2 * deltaY))) / __formHeight;
+                       temp = width - temp;
+                       if (__cropBox.height - (2 * deltaY) > (__formHeight * (H_CROP_RECTANGLE * 3)) / __formWidth && (!(__cropBox.height - (2 * deltaY) >= __imageBox.height || width >= __imageBox.width)))
+                       {
+                               if (__cropBox.x - (temp /2 ) > __imageBox.x && __cropBox.x + __cropBox.width + temp < __imageBox.x + __imageBox.width
+                                       && __cropBox.y + (deltaY) > __imageBox.y && __cropBox.y + __cropBox.height - (2 * deltaY) < __imageBox.y + __imageBox.height)
+                               {
+                                       __cropBox.y += deltaY;
+                                       __cropBox.height = __cropBox.height - (2 * deltaY);
+                                       __cropBox.width = width;
+                                       __cropBox.x = __cropBox.x - (temp / 2);
+                               }
+                               else if (__cropBox.x - (temp / 2) < __imageBox.x)
+                               {
+                                       if (__cropBox.x + __cropBox.width + temp <= __imageBox.x + __imageBox.width)
+                                       {
+                                               __cropBox.width = width;
+                                       }
+                                       if (__cropBox.y + deltaY >= __imageBox.y)
+                                       {
+                                               __cropBox.y += deltaY;
+                                       }
+                                       if (__cropBox.y + __cropBox.height - (2 * deltaY) < __imageBox.y + __imageBox.height)
+                                       {
+                                               __cropBox.height = __cropBox.height - (2 * deltaY);
+                                       }
+                               }
+                               else if (__cropBox.y + __cropBox.height - (2 * deltaY) >= __imageBox.x + __imageBox.height
+                                               && __cropBox.y + (2 * deltaY) >= __imageBox.y)
+                               {
+                                       if (__cropBox.x - temp >= __imageBox.x
+                                               && __cropBox.x + __cropBox.width + temp > __imageBox.x + __imageBox.width)
+                                       {
+                                               __cropBox.x = __cropBox.x - temp;
+                                       }
+                                       else if (__cropBox.x - temp >= __imageBox.x)
+                                       {
+                                               __cropBox.x = __cropBox.x - temp / 2;
+                                       }
+                                       if (__cropBox.x + __cropBox.width + temp <= __imageBox.x + __imageBox.width)
+                                       {
+                                               __cropBox.width = width;
+                                       }
+                                       if (__cropBox.y + (2 * deltaY) >= __imageBox.y)
+                                       {
+                                               __cropBox.y = __cropBox.y + (2 * deltaY);
+                                               __cropBox.height = __cropBox.height - (2 * deltaY);
+                                       }
+                               }
+                               else if (__cropBox.x + __cropBox.width + (temp / 2) > __imageBox.x + __imageBox.width
+                                               && __cropBox.x - temp >= __imageBox.x && __cropBox.y + deltaY >= __imageBox.y
+                                               && __cropBox.y + __cropBox.height - (2 * deltaY) <= __imageBox.y + __imageBox.height)
+                               {
+                                       __cropBox.x = __cropBox.x - temp;
+                                       __cropBox.width = width;
+                                       __cropBox.y += deltaY;
+                                       __cropBox.height = __cropBox.height - (2 * deltaY);
+                               }
+                       }
+               }
+               else if (__pointLocation == INSIDE_BOTTOM_RECTANGLE)
+               {
+                       deltaY = deltaY * (-1);
+                       int temp = __cropBox.width;
+                       int width = (__formWidth * (__cropBox.height - (2 * deltaY))) / __formHeight;
+                       temp = width - temp;
+                       if (__cropBox.height - (2 * deltaY) > (__formHeight * (H_CROP_RECTANGLE * 3)) / __formWidth && (!(__cropBox.height - (2 * deltaY) >= __imageBox.height || width >= __imageBox.width)))
+                       {
+                               if (__cropBox.x - (temp / 2) >= __imageBox.x && __cropBox.x + __cropBox.width + temp < __imageBox.x + __imageBox.width
+                                       && __cropBox.y + deltaY > __imageBox.y && __cropBox.y + __cropBox.height - (2 * deltaY) < __imageBox.y + __imageBox.height)
+                               {
+                                       __cropBox.y += deltaY;
+                                       __cropBox.height = __cropBox.height - (2 * deltaY);;
+                                       __cropBox.width = width;
+                                       __cropBox.x = __cropBox.x - (temp / 2);
+                               }
+                               else if (__cropBox.y + deltaY < __imageBox.y && __cropBox.y + __cropBox.height - (2 * deltaY) < __imageBox.y + __imageBox.height
+                                               && __cropBox.x - (temp / 2) > __imageBox.x && __cropBox.x + __cropBox.width + temp < __imageBox.x + __imageBox.width)
+                               {
+                                       __cropBox.x = __cropBox.x - (temp / 2);
+                                       __cropBox.width = width;
+                                       __cropBox.height = __cropBox.height - (2 * deltaY);
+                               }
+                               else if (__cropBox.x + __cropBox.width + temp > __imageBox.x + __imageBox.width
+                                               && __cropBox.y + deltaY >= __imageBox.y && __cropBox.y + __cropBox.height + temp <= __imageBox.y + __imageBox.height
+                                               && __cropBox.x - temp >= __imageBox.x)
+                               {
+                                       __cropBox.x = __cropBox.x - temp;
+                                       __cropBox.y += deltaY;
+                                       __cropBox.width = width;
+                                       __cropBox.height = __cropBox.height - (2 * deltaY);
+                               }
+                               else if (__cropBox.x + __cropBox.width + temp >= __imageBox.x + __imageBox.width
+                                               && __cropBox.y + deltaY <= __imageBox.y && __cropBox.x - temp > __imageBox.x
+                                               && __cropBox.y + __cropBox.height + temp < __imageBox.y + __imageBox.height)
+                               {
+                                       __cropBox.x -= temp;
+                                       __cropBox.width = width;
+                                       __cropBox.height = __cropBox.height - (2 * deltaY);
+                               }
+                               else if (__cropBox.x - temp < __imageBox.x && __cropBox.x + __cropBox.width + temp <= __imageBox.x + __imageBox.width
+                                               && __cropBox.y + __cropBox.height - (2 * deltaY) <= __imageBox.y + __imageBox.height)
+                               {
+                                       if (__cropBox.y + deltaY >= __imageBox.y)
+                                       {
+                                               __cropBox.y += deltaY;
+                                       }
+                                       __cropBox.width = width;
+                                       __cropBox.height = __cropBox.height - (2 * deltaY);
+                               }
+                       }
+               }
+               else if (__pointLocation == INSIDE_CROPBOX)
+               {
+                       if ((__cropBox.x + deltaX) > __imageBox.x)
+                       {
+                               __cropBox.x += deltaX;
+                       }
+                       else
+                       {
+                               __cropBox.x = __imageBox.x;
+                       }
+                       if ((__cropBox.y + deltaY) > __imageBox.y)
+                       {
+                               __cropBox.y += deltaY;
+                       }
+                       else
+                       {
+                               __cropBox.y = __imageBox.y;
+                       }
+                       if ((__cropBox.x + __cropBox.width + deltaX) > (__imageBox.x + __imageBox.width))
+                       {
+                               __cropBox.x = __imageBox.x + __imageBox.width - __cropBox.width;
+                       }
+                       if ((__cropBox.y + __cropBox.height + deltaY) > (__imageBox.y + __imageBox.height))
+                       {
+                               __cropBox.y = __imageBox.y + __imageBox.height - __cropBox.height;
+                       }
+               }
+       }
+       RequestRedraw(false);
+       __touchStart = currentPosition;
+}
+
+void
+ImageCropForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+       AppLogDebug("OnTouchReleased");
+
+       __pointLocation = OUTSIDE_CROPBOX;
+}
+
+void
+ImageCropForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
+{
+       AppLogDebug("OnSceneActivatedN");
+
+       if (pArgs != null)
+       {
+               __sourceFilePath = *(static_cast<String*>(pArgs->GetAt(0)));
+               pArgs->RemoveAll(true);
+               delete pArgs;
+
+               if (__sourceFilePath.IsEmpty() == false)
+               {
+                       result r = __imageBuffer.Construct(__sourceFilePath.GetPointer());
+                       if (r == E_SUCCESS)
+                       {
+                               __imageWidth = __imageBuffer.GetWidth();
+                               __imageHeight = __imageBuffer.GetHeight();
+
+                               int physicalHeight = CoordinateSystem::ConvertToPhysicalY(__imageHeight);
+                               int physicalWidth = CoordinateSystem::ConvertToPhysicalX(__imageWidth);
+                               __pCurrentBitmap = __imageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, physicalWidth, physicalHeight);
+                               SetValue();
+
+                               Image img;
+                               r = img.Construct();
+                               if (r == E_SUCCESS)
+                               {
+                                       __imageFormat = img.GetImageFormat(__sourceFilePath);
+                               }
+                       }
+                       else
+                       {
+                               GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
+                               if (pApp != null && pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_PICK)
+                               {
+                                       pApp->SendAppControlResult(APP_CTRL_RESULT_FAILED, null);
+                                       pApp->Terminate();
+                               }
+                       }
+               }
+       }
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+void
+ImageCropForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
+{
+       AppLogDebug("OnSceneDeactivated");
+
+       RemoveOrientationEventListener(*this);
+}
+
+void
+ImageCropForm::CheckCurrentPosition(const Point currentPosition)
+{
+       AppLogDebug("CheckCurrentPosition");
+
+       if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET)
+               && currentPosition.y >  (__cropBox.y - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.y < (__cropBox.y + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET))
+       {
+               __pointLocation = INSIDE_TOP_RECTANGLE;
+       }
+       else if (currentPosition.x > (__cropBox.x - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.x < (__cropBox.x + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET)
+               && currentPosition.y >  ((__cropBox.y + __cropBox.height / 2) - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET))
+       {
+               __pointLocation = INSIDE_LEFT_RECTANGLE;
+       }
+       else if (currentPosition.x > (__cropBox.x + __cropBox.width - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.x < (__cropBox.x + __cropBox.width + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET)
+               && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET))
+       {
+               __pointLocation = INSIDE_RIGHT_RECTANGLE;
+       }
+       else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET)
+               && currentPosition.y > (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.y < (__cropBox.y + __cropBox.height + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET))
+       {
+               __pointLocation = INSIDE_BOTTOM_RECTANGLE;
+       }
+       else if (currentPosition.x > (__cropBox.x - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.x < (__cropBox.x + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET)
+                        && currentPosition.y > (__cropBox.y - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.y < (__cropBox.y +(H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET))
+       {
+               __pointLocation = INSIDE_TOP_LEFT_RECTANGLE;
+       }
+       else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.x < (__cropBox.x + __cropBox.width + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET)
+                       && currentPosition.y > (__cropBox.y - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.y < (__cropBox.y +(H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET))
+       {
+               __pointLocation = INSIDE_TOP_RIGHT_RECTANGLE;
+       }
+       else if (currentPosition.x > (__cropBox.x + __cropBox.width - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.x < (__cropBox.x + __cropBox.width + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET)
+                       && currentPosition.y > (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.y < (__cropBox.y + __cropBox.height + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET))
+       {
+               __pointLocation = INSIDE_BOTTOM_RIGHT_RECTANGLE;
+       }
+       else if (currentPosition.x > (__cropBox.x - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.x < (__cropBox.x + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET)
+                       && currentPosition.y > (__cropBox.y + __cropBox.height - (H_CROP_RECTANGLE / 2) - CROP_BOX_OFFSET) && currentPosition.y < (__cropBox.y + __cropBox.height + (H_CROP_RECTANGLE / 2) + CROP_BOX_OFFSET))
+       {
+               __pointLocation = INSIDE_BOTTOM_LEFT_RECTANGLE;
+       }
+       else if (currentPosition.x > __cropBox.x && currentPosition.x < (__cropBox.x + __cropBox.width) && currentPosition.y > __cropBox.y && currentPosition.y < (__cropBox.y + __cropBox.height))
+       {
+               __pointLocation = INSIDE_CROPBOX;
+       }
+       else
+       {
+               __pointLocation = OUTSIDE_CROPBOX;
+       }
+       return;
+}
+
+void
+ImageCropForm::SetValue(void)
+{
+       int prevHeight = __imageBox.height;
+       int prevWidth = __imageBox.width;
+       int prevImageboxX = __imageBox.x;
+       int prevImageBoxY = __imageBox.y;
+
+       if (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
+       {
+               __formHeight = Form::GetBounds().height;
+               __formWidth = Form::GetBounds().width;
+       }
+       else if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
+       {
+               __formHeight = Form::GetBounds().width;
+               __formWidth = Form::GetBounds().height;
+       }
+
+       float clientAreaRatio = (GetClientAreaBoundsF().height) / GetClientAreaBoundsF().width;
+
+       if (__imageWidth >= GetClientAreaBounds().width || __imageHeight > GetClientAreaBounds().height)
+       {
+               float imageRatio = __imageHeight / (float) __imageWidth;
+               if (imageRatio < clientAreaRatio)
+               {
+                       __imageBox.width = GetClientAreaBounds().width;
+                       __imageBox.height = (__imageHeight * __imageBox.width) / __imageWidth;
+                       __imageBox.x = GetClientAreaBounds().x;
+                       __imageBox.y = GetClientAreaBounds().y + (GetClientAreaBounds().height - __imageBox.height) / 2;
+               }
+               else
+               {
+                       __imageBox.height = GetClientAreaBounds().height;
+                       __imageBox.width = (__imageWidth * __imageBox.height) / __imageHeight;
+                       __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
+                       __imageBox.y = GetClientAreaBounds().y;
+               }
+       }
+       else
+       {
+               __imageBox.height = __imageHeight;
+               __imageBox.width = __imageWidth;
+               __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
+               __imageBox.y = GetClientAreaBounds().y + (GetClientAreaBounds().height - __imageBox.height) / 2 ;
+       }
+       if (__isOrientationChanged == false)
+       {
+               if (__imageBox.height > __imageBox.width)
+               {
+                       __cropBox.width = (2 * __imageBox.width) / 3;
+                       __cropBox.height = (__formHeight * __cropBox.width / __formWidth);
+                       if (__cropBox.height > __imageBox.height)
+                       {
+                               __cropBox.height = (2 * __imageBox.height) / 3;
+                               __cropBox.width = (__cropBox.height * __formWidth) / __formHeight;
+                       }
+                       __cropBox.y =  __imageBox.y + (__imageBox.height - __cropBox.height) / 2;
+                       __cropBox.x = __imageBox.x + (__imageBox.width - __cropBox.width) / 2;
+               }
+               else
+               {
+                       __cropBox.height = (2 *__imageBox.height) / 3;
+                       __cropBox.width = (__formWidth * __cropBox.height / __formHeight);
+                       if (__cropBox.width > __imageBox.width)
+                       {
+                               __cropBox.width = (2 * __imageBox.width) / 3;
+                               __cropBox.height = (__formHeight * __cropBox.width) / __formWidth;
+                       }
+                       __cropBox.y = __imageBox.y + (__imageBox.height - __cropBox.height) / 2;
+                       __cropBox.x = __imageBox.x + (__imageBox.width - __cropBox.width) / 2;
+               }
+       }
+       else
+       {
+               float temp = __imageBox.x + ((__cropBox.x - prevImageboxX) * __imageBox.width) / (float) prevWidth;
+               __cropBox.x = (temp + 0.5);
+               temp = __imageBox.y + ((__cropBox.y - prevImageBoxY) * __imageBox.height) / (float) prevHeight;
+               __cropBox.y = (temp + 0.5);
+               temp = (__cropBox.height * __imageBox.height) / (float) prevHeight;
+               __cropBox.height = (temp + 0.5);
+               temp = (__cropBox.width * __imageBox.width) / (float) prevWidth;
+               __cropBox.width = (temp + 0.5);
+       }
+       __pCanvas = GetCanvasN(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height));
+       if (__pCanvas != null)
+       {
+               __pCanvas->SetBackgroundColor(COLOR_GALLERY_BG);
+               __pCanvas->SetForegroundColor(CROP_BOX_RECTANGLE_COLOR);
+       }
+}
+
+String
+ImageCropForm::GetFileName(const String& filePath, bool isCheckExe) const
+{
+       String strResult;
+       int lastIndex = -1 ;
+
+       filePath.LastIndexOf(DIRECTORY_SEPARATOR, filePath.GetLength() - 1, lastIndex);
+       filePath.SubString(lastIndex+1, strResult);
+
+       if (isCheckExe == true)
+       {
+               String strTemp = strResult;
+
+               lastIndex = -1;
+               strTemp.LastIndexOf(FILE_EXT_SEPARATOR, strTemp.GetLength() - 1, lastIndex);
+               strTemp.SubString(0, lastIndex, strResult);
+       }
+
+       return strResult;
+}
index 92efa70..b41ee95 100644 (file)
@@ -350,39 +350,52 @@ ImageListEditorPanel::OnIconListViewItemStateChanged(IconListView& view, int ind
        {
                if (status == ICON_LIST_VIEW_ITEM_SELECTED)
                {
-                       HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
-                       result r = pMap->Construct();
-                       if (r == E_SUCCESS)
-                       {
-                               ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
-                               r = pArrayList->Construct();
+                       GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
+                       const IMap* pArguments = pApp->GetAppControlArguments();
 
+                       const String* cropMode = static_cast<const String*>(pArguments->GetValue(String(APPCONTROL_KEY_IMAGEVIEWER_MODE)));
+                       if (cropMode != null)
+                       {
+                               ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+                               pList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
+                               SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
+                       }
+                       else
+                       {
+                               HashMap* pMap = new (std::nothrow) HashMap(SingleObjectDeleter);
+                               result r = pMap->Construct();
                                if (r == E_SUCCESS)
                                {
-                                       pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
-                                       pMap->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
+                                       ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+                                       r = pArrayList->Construct();
 
-                                       GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
-                                       if (pApp != null)
+                                       if (r == E_SUCCESS)
                                        {
-                                               pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, pMap);
-                                               pApp->Terminate();
+                                               pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(index)));
+                                               pMap->Add(new (std::nothrow) String(APPCONTROL_KEY_DATA_SELECTED), (Object*)pArrayList);
+
+                                               GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
+                                               if (pApp != null)
+                                               {
+                                                       pApp->SendAppControlResult(APP_CTRL_RESULT_SUCCEEDED, pMap);
+                                                       pApp->Terminate();
+                                               }
+                                               else
+                                               {
+                                                       delete pMap;
+                                               }
                                        }
                                        else
                                        {
+                                               delete pArrayList;
                                                delete pMap;
                                        }
                                }
                                else
                                {
-                                       delete pArrayList;
                                        delete pMap;
                                }
                        }
-                       else
-                       {
-                               delete pMap;
-                       }
                }
        }
        SetButtonState();
index 8fdd34b..975b73f 100644 (file)
@@ -77,6 +77,7 @@ MainFrame::OnInitializing(void)
        r = pSceneManager->RegisterScene(IDSCN_SETTING_MAIN, IDC_FORM_SETTING_MAIN, IDC_PANEL_BLANK);
        r = pSceneManager->RegisterScene(IDSCN_SETTING_INTERVAL, IDC_FORM_SETTING_INTERVAL, IDC_PANEL_BLANK);
        r = pSceneManager->RegisterScene(IDSCN_SETTING_TRANSITION, IDC_FORM_SETTING_TRANSITION, IDC_PANEL_BLANK);
+       r = pSceneManager->RegisterScene(IDSCN_IMAGE_CROP, IDC_FORM_IMAGE_CROP, IDC_PANEL_BLANK);
 
        SceneId sceneId;
        GalleryApp* pGalleryApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
index 1e94bab..3f4e631 100644 (file)
@@ -30,6 +30,7 @@ const wchar_t* IDL_FORM_FILE_LIST = L"IDL_FORM_FILE_LIST";
 const wchar_t* IDL_FORM_SETTING_MAIN = L"IDL_FORM_SETTING_MAIN";
 const wchar_t* IDL_FORM_SETTING_INTERVAL = L"IDL_FORM_SETTING_INTERVAL";
 const wchar_t* IDL_FORM_SETTING_TRANSITION = L"IDL_FORM_SETTING_TRANSITION";
+const wchar_t* IDL_FORM_IMAGE_CROP = L"IDL_FORM_IMAGE_CROP";
 
 const wchar_t* IDC_LABEL_ALBUM_LIST_EDITOR_SELECTED = L"IDC_LABEL_ALBUM_LIST_EDITOR_SELECTED";
 
@@ -41,6 +42,7 @@ const wchar_t* IDC_FORM_FILE_LIST_EDITOR = L"FileListEditorForm";
 const wchar_t* IDC_FORM_SETTING_MAIN = L"SettingMainForm";
 const wchar_t* IDC_FORM_SETTING_INTERVAL = L"SettingIntervalForm";
 const wchar_t* IDC_FORM_SETTING_TRANSITION = L"SettingTransitionForm";
+const wchar_t* IDC_FORM_IMAGE_CROP = L"ImageCropForm";
 
 const wchar_t* IDC_PANEL_BLANK = L"";
 const wchar_t* IDC_PANEL_ALL_LIST = L"AllListPanel";
@@ -64,6 +66,7 @@ const wchar_t* IDSCN_ALL_LIST_SELECTION = L"SceneFileAllListSelection";
 const wchar_t* IDSCN_SETTING_MAIN = L"SceneMainSetting";
 const wchar_t* IDSCN_SETTING_INTERVAL = L"SceneInvervalSetting";
 const wchar_t* IDSCN_SETTING_TRANSITION = L"SceneTransitionSetting";
+const wchar_t* IDSCN_IMAGE_CROP = L"SceneImageCrop";
 
 const wchar_t* APPCONTROL_PROVIDER_ID_CAMERA = L"tizen.camera";
 const wchar_t* APPCONTROL_PROVIDER_ID_MESSAGE = L"tizen.messages";
@@ -84,6 +87,7 @@ const wchar_t* APPCONTROL_KEY_SELECTION_MODE = L"http://tizen.org/appcontrol/dat
 const wchar_t* APPCONTROL_KEY_DATA_SELECTED = L"http://tizen.org/appcontrol/data/selected";
 const wchar_t* APPCONTROL_KEY_MESSAGE_TYPE = L"http://tizen.org/appcontrol/data/message/type";
 const wchar_t* APPCONTROL_KEY_CAMERA_ALLOW_SWITCH = L"http://tizen.org/appcontrol/data/camera/allow_switch";
+const wchar_t* APPCONTROL_KEY_IMAGEVIEWER_MODE = L"http://tizen.org/appcontrol/data/image/crop_mode";
 
 const wchar_t* APPCONTROL_URI_MMS_TO = L"mmsto";
 const wchar_t* APPCONTROL_URI_MAIL_TO = L"mailto";
@@ -99,6 +103,8 @@ const wchar_t* APPCONTROL_DATA_SLIDE_SHOW = L"slideshow";
 const wchar_t* APPCONTROL_DATA_SELECTION_MODE = L"http://tizen.org/appcontrol/data/selection/mode";
 const wchar_t* APPCONTROL_DATA_TRUE = L"true";
 const wchar_t* APPCONTROL_DATA_MMS = L"mms";
+const wchar_t* APPCONTROL_DATA_CROP_TYPE_AUTO = L"auto";
+const wchar_t* APPCONTROL_DATA_CROP_TYPE_FIT_TO_SCREEN = L"fit_to_screen";
 
 const wchar_t* APPCONTROL_RESULT_KEY_LEGACY_RESULT = L"http://tizen.org/appcontrol/data/legacyresult";
 
@@ -208,3 +214,5 @@ const wchar_t* IDB_ALBUM_RENAME_PROGRESS30 = L"00_list_process_30.png";
 
 const wchar_t* IDB_IMAGE_CONTEXT_EMAIL_ICON = L"T01_1_face_tag_icon_email.png";
 const wchar_t* IDB_IMAGE_CONTEXT_MESSAGE_ICON =  L"T01_1_face_tag_icon_message.png";
+
+const wchar_t* IDB_IMAGE_CROP_RECTANGLE = L"T01-1_crop_rectangle.png";