#include <FApp.h>
#include <FMedia.h>
+#include <FSystem.h>
+#include <FSocial.h>
#include "IvImageCropForm.h"
#include "IvImageViewerPresentationModel.h"
#include "IvResourceManager.h"
using namespace Tizen::Graphics;
using namespace Tizen::Io;
using namespace Tizen::Media;
+using namespace Tizen::System;
+using namespace Tizen::Social;
using namespace Tizen::Ui::Controls;
using namespace Tizen::Ui::Scenes;
}
AddTouchEventListener(*this);
AddOrientationEventListener(*this);
+ __pPresentationModel->AddFileUpdateListener(this);
delete pCWRotationButtonBitmap;
delete pCCWRotationButtonBitmap;
ImageCropForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
{
AppLogDebug("ENTER pArgs(%x)", pArgs);
- String filePath;
if (pArgs != null)
{
- filePath = *(static_cast<String*>(pArgs->GetAt(0)));
- delete pArgs;
- }
- else
- {
- filePath = __pPresentationModel->GetFilePathAt(0);
- }
+ IEnumerator* pEnum = pArgs->GetEnumeratorN();
+ if (pEnum->MoveNext() != E_SUCCESS)
+ {
+ delete pEnum;
+ delete pArgs;
+ AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
- if (filePath.IsEmpty() == false)
- {
- __sourceFilePath.Append(filePath);
+ return;
+ }
+ __sourceFilePath = *(static_cast<String*>(pEnum->GetCurrent()));
+ if (__sourceFilePath.IsEmpty() == false)
+ {
+ result r = __imageBuffer.Construct(__sourceFilePath.GetPointer());
+ if (r == E_SUCCESS)
+ {
+ __imageWidth = __imageBuffer.GetWidth();
+ __imageHeight = __imageBuffer.GetHeight();
+ __pCurrentBitmap = __imageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_RGB565, BUFFER_SCALING_AUTO);
+ }
+ Image img;
+ __imageFormat = img.GetImageFormat(__sourceFilePath);
+ }
+ if (pEnum->MoveNext() != E_SUCCESS)
+ {
+ delete pEnum;
+ delete pArgs;
+ AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
+
+ return;
+ }
+ __cropMode = *(static_cast<String*>(pEnum->GetCurrent()));
+ if (__cropMode.IsEmpty() == false)
+ {
+ __cropMode.ToLowerCase();
+ if (__cropMode == "auto")
+ {
+ delete pEnum;
+ delete pArgs;
+ SetValue();
+ return;
+ }
+ else if (__cropMode == "fit-to-screen")
+ {
+ if (pEnum->MoveNext() != E_SUCCESS)
+ {
+ delete pEnum;
+ delete pArgs;
+ AppLogDebug("EXIT 3(%s)", GetErrorMessage(GetLastResult()));
+
+ return;
+ }
+ Integer *pStatus = static_cast<Integer*>(pEnum->GetCurrent());
+ if (pStatus != null)
+ {
+ __statusValue = pStatus->ToInt();
+ }
+ if (__statusValue == SET_AT_TYPE_CALLER_IMAGE)
+ {
+ if (pEnum->MoveNext() != E_SUCCESS)
+ {
+ delete pEnum;
+ delete pArgs;
+ AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
+
+ return;
+ }
+
+ LongLong* pContentId = static_cast<LongLong*>(pEnum->GetCurrent());
+ if (pContentId != null)
+ {
+ __contentId = pContentId->ToLongLong();
+ }
+ }
+
+ delete pEnum;
+ delete pArgs;
+ SetValue();
+ }
+ }
+ }
+// if (pArgs != null)
+// {
+// __sourceFilePath = *(static_cast<String*>(pArgs->GetAt(0)));
+// __cropMode = *(static_cast<String*>(pArgs->GetAt(1)));
+// delete pArgs;
+// }
+// else
+// {
+// __sourceFilePath = __pPresentationModel->GetFilePathAt(0);
+// }
+/* if (__sourceFilePath.IsEmpty() == false && __cropMode.IsEmpty() == false)
+ {
+ __cropMode.ToLowerCase();
result r = __imageBuffer.Construct(__sourceFilePath.GetPointer());
if (r == E_SUCCESS)
{
}
Image img;
__imageFormat = img.GetImageFormat(__sourceFilePath);
- }
+ }*/
SetValue();
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}
break;
case IDA_BUTTON_SAVE:
{
- ImageBuffer* pCropBuffer = null;
- int count = 1;
- int index = 0;
- String destFilePath;
- String stringToInsert = L"_";
- String delimiter = L".";
- if (__sourceFilePath.IsEmpty() == false)
+ if (__cropMode == "auto")
{
- __sourceFilePath.Reverse();
- __sourceFilePath.IndexOf(delimiter, 0, index);
- __sourceFilePath.Reverse();
- __sourceFilePath.Insert(stringToInsert, __sourceFilePath.GetLength() - index - 1);
- destFilePath.Append(__sourceFilePath);
- destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
- while (File::IsFileExist(destFilePath) == true)
- {
- count++;
- destFilePath.Clear();
+ ImageBuffer* pCropBuffer = null;
+ int count = 1;
+ int index = 0;
+ String destFilePath;
+ String stringToInsert = L"_";
+ String delimiter = L".";
+ if (__sourceFilePath.IsEmpty() == false)
+ {
+ __sourceFilePath.Reverse();
+ __sourceFilePath.IndexOf(delimiter, 0, index);
+ __sourceFilePath.Reverse();
+ __sourceFilePath.Insert(stringToInsert, __sourceFilePath.GetLength() - index - 1);
destFilePath.Append(__sourceFilePath);
destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
+ while (File::IsFileExist(destFilePath) == true)
+ {
+ count++;
+ destFilePath.Clear();
+ destFilePath.Append(__sourceFilePath);
+ destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
+ }
+ 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);
+ pCropBuffer->EncodeToFile(destFilePath, __imageFormat, true, 100);
+ ContentManager::ScanFile(destFilePath);
+ delete pCropBuffer;
}
+ ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+ pList->Add(new (std::nothrow) String(destFilePath));
+ pSceneManager->GoBackward(BackwardSceneTransition(), pList);
+ }
+ else if(__cropMode == "fit-to-screen")
+ {
+ ImageBuffer* pCropBuffer = null;
+ result r = E_SUCCESS;
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);
- pCropBuffer->EncodeToFile(destFilePath, __imageFormat, true, 100);
- ContentManager::ScanFile(destFilePath);
+ (__cropBox.width * __imageWidth) / __imageBox.width, (__cropBox.height * __imageHeight) / __imageBox.height);
+ if (__statusValue == SET_AT_TYPE_HOME_SCREEN_WALLPAPER)
+ {
+ String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_HOME_SCREEN_WALLPAPER;
+ r = pCropBuffer->EncodeToFile(destPath, __imageFormat, true, 100);
+ if (r == E_SUCCESS)
+ {
+ r = SettingInfo::SetValue(SETTING_VALUE_HOME_SCREEN_WALLPAPER, destPath);
+ }
+ else if (r == E_OVERFLOW)
+ {
+ MessageBox messageBox;
+ messageBox.Construct(L"", L"File size is too big", MSGBOX_STYLE_NONE, 3000);
+ int modalResult = 0;
+ messageBox.ShowAndWait(modalResult);
+ }
+ }
+ else if (__statusValue == SET_AT_TYPE_LOCK_SCREEN_WALLPAPER)
+ {
+ String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_LOCK_SCREEN_WALLPAPER;
+ r = pCropBuffer->EncodeToFile(destPath, __imageFormat, true, 100);
+ if (r == E_SUCCESS)
+ {
+ r = SettingInfo::SetValue(SETTING_VALUE_LOCK_SCREEN_WALLPAPER, destPath);
+ }
+ else if (r == E_OVERFLOW)
+ {
+ MessageBox messageBox;
+ messageBox.Construct(L"", L"File size is too big", MSGBOX_STYLE_NONE, 3000);
+ int modalResult = 0;
+ messageBox.ShowAndWait(modalResult);
+ }
+ }
+ else if (__statusValue == SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER)
+ {
+ String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_LOCK_SCREEN_WALLPAPER;
+ String destPathHome = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_HOME_SCREEN_WALLPAPER;
+ r = pCropBuffer->EncodeToFile(destPath, __imageFormat, true, 100);
+ r = pCropBuffer->EncodeToFile(destPathHome, __imageFormat, true, 100);
+ if (r == E_SUCCESS)
+ {
+ r = SettingInfo::SetValue(SETTING_VALUE_LOCK_SCREEN_WALLPAPER, destPath);
+ r = SettingInfo::SetValue(SETTING_VALUE_HOME_SCREEN_WALLPAPER, destPathHome);
+ }
+ else if (r == E_OVERFLOW)
+ {
+ MessageBox messageBox;
+ messageBox.Construct(L"", L"File size is too big", MSGBOX_STYLE_NONE, 3000);
+ int modalResult = 0;
+ messageBox.ShowAndWait(modalResult);
+ }
+ }
+ else if (__statusValue == SET_AT_TYPE_CALLER_IMAGE)
+ {
+ int count = 1;
+ int index = 0;
+ String destFilePath;
+ String stringToInsert = L"_";
+ String delimiter = L".";
+ if (__sourceFilePath.IsEmpty() == false)
+ {
+ __sourceFilePath.Reverse();
+ __sourceFilePath.IndexOf(delimiter, 0, index);
+ __sourceFilePath.Reverse();
+ __sourceFilePath.Insert(stringToInsert, __sourceFilePath.GetLength() - index - 1);
+ destFilePath.Append(__sourceFilePath);
+ destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
+ while (File::IsFileExist(destFilePath) == true)
+ {
+ count++;
+ destFilePath.Clear();
+ destFilePath.Append(__sourceFilePath);
+ destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
+ }
+ }
+ r = pCropBuffer->EncodeToFile(destFilePath, __imageFormat, true, 100);
+ ContentManager::ScanFile(destFilePath);
+ Contact* pContact = null;
+ AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
+ Addressbook* pAddressbook = null;
+
+ pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
+ pContact = pAddressbook->GetContactN(__contentId);
+ pContact->SetThumbnail(destFilePath);
+ pAddressbook->UpdateContact(*pContact);
+
+ delete pContact;
+ delete pAddressbook;
+ }
delete pCropBuffer;
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_VIEWER));
}
- ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
- pList->Add(new (std::nothrow) String(destFilePath));
- AppLog("Manish %ls", destFilePath.GetPointer());
- pSceneManager->GoBackward(BackwardSceneTransition(), pList);
- AppLog("Exit");
}
break;
}
+ AppLog("Exit");
}
void
AppLogDebug("ENTER");
int deltaX = currentPosition.x - __touchStart.x;
int deltaY = currentPosition.y - __touchStart.y;
- switch(__pointLocation)
+ if (__cropMode.Equals("auto", false))
{
- case INSIDE_TOP_RECTANGLE:
- {
- if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3)))
+ switch(__pointLocation)
+ {
+ case INSIDE_TOP_RECTANGLE:
{
- __cropBox.y += deltaY;
- __cropBox.height -= deltaY;
+ if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3)))
+ {
+ __cropBox.y += deltaY;
+ __cropBox.height -= deltaY;
+ }
}
- }
- break;
+ break;
- case INSIDE_BOTTOM_RECTANGLE:
- {
- if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height)
- && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
+ case INSIDE_BOTTOM_RECTANGLE:
{
- __cropBox.height += deltaY;
+ if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height)
+ && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
+ {
+ __cropBox.height += deltaY;
+ }
}
- }
- break;
+ break;
- case INSIDE_LEFT_RECTANGLE:
- {
- if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
+ case INSIDE_LEFT_RECTANGLE:
{
- __cropBox.x += deltaX;
- __cropBox.width -= deltaX;
+ if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
+ {
+ __cropBox.x += deltaX;
+ __cropBox.width -= deltaX;
+ }
}
- }
- break;
+ break;
- case INSIDE_RIGHT_RECTANGLE:
- {
- if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width)
- && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
+ case INSIDE_RIGHT_RECTANGLE:
{
- __cropBox.width += deltaX;
+ if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width)
+ && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
+ {
+ __cropBox.width += deltaX;
+ }
}
- }
- break;
+ break;
- case INSIDE_TOP_LEFT_RECTANGLE:
- {
- if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
- && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
+ case INSIDE_TOP_LEFT_RECTANGLE:
{
- __cropBox.y += deltaY;
- __cropBox.height -= deltaY;
- __cropBox.x += deltaX;
- __cropBox.width -= deltaX;
+ if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
+ && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
+ {
+ __cropBox.y += deltaY;
+ __cropBox.height -= deltaY;
+ __cropBox.x += deltaX;
+ __cropBox.width -= deltaX;
+ }
}
- }
- break;
+ break;
- case INSIDE_TOP_RIGHT_RECTANGLE:
- {
- if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
- && (__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
+ case INSIDE_TOP_RIGHT_RECTANGLE:
{
- __cropBox.width += deltaX;
- __cropBox.y += deltaY;
- __cropBox.height -= deltaY;
+ if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
+ && (__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
+ {
+ __cropBox.width += deltaX;
+ __cropBox.y += deltaY;
+ __cropBox.height -= deltaY;
+ }
}
- }
- break;
+ break;
- case INSIDE_BOTTOM_LEFT_RECTANGLE:
- {
- if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3)
- && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
+ case INSIDE_BOTTOM_LEFT_RECTANGLE:
{
- __cropBox.x += deltaX;
- __cropBox.width -= deltaX;
- __cropBox.height += deltaY;
+ if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3)
+ && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
+ {
+ __cropBox.x += deltaX;
+ __cropBox.width -= deltaX;
+ __cropBox.height += deltaY;
+ }
}
- }
- break;
+ break;
- case INSIDE_BOTTOM_RIGHT_RECTANGLE:
- {
- if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3)
- && (__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
+ case INSIDE_BOTTOM_RIGHT_RECTANGLE:
{
- __cropBox.width += deltaX;
- __cropBox.height += deltaY;
+ if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3)
+ && (__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
+ {
+ __cropBox.width += deltaX;
+ __cropBox.height += deltaY;
+ }
}
- }
- break;
+ break;
- case INSIDE_CROPBOX:
- {
- if ((__cropBox.x + deltaX) > __imageBox.x)
+ case INSIDE_CROPBOX:
{
- __cropBox.x += deltaX;
+ 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;
+ }
}
- else
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if (__cropMode != "auto")
+ {
+ if (__pointLocation == INSIDE_LEFT_RECTANGLE || __pointLocation == INSIDE_BOTTOM_LEFT_RECTANGLE
+ || __pointLocation == INSIDE_TOP_LEFT_RECTANGLE)
{
- __cropBox.x = __imageBox.x;
+ int temp = __cropBox.height;
+ int height = (__formHeight * (__cropBox.width - (2 * deltaX))) /__formWidth;
+ temp = height - temp;
+ if ((__cropBox.width - (2 * deltaX) > (CROP_RECTANGLE_HEIGHT * 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) > (CROP_RECTANGLE_HEIGHT * 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;
+ }
+ }
}
- if ((__cropBox.y + deltaY) > __imageBox.y)
+ else if (__pointLocation == INSIDE_RIGHT_RECTANGLE || __pointLocation == INSIDE_BOTTOM_RIGHT_RECTANGLE
+ || __pointLocation == INSIDE_TOP_RIGHT_RECTANGLE)
{
- __cropBox.y += deltaY;
+ deltaX *= -1;
+
+ int temp = __cropBox.height;
+ int height = (__formHeight * (__cropBox.width - (2 * deltaX))) / __formWidth;
+ temp = height - temp;
+ if ((__cropBox.width - (2 * deltaX) > (CROP_RECTANGLE_HEIGHT * 3)) && (!(height >= __imageBox.height || (__cropBox.width - (2 * deltaX)) >= __imageBox.width)))
+ {
+ if (deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 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;
+ }
+ else
+ {
+ __cropBox.width = __cropBox.width - (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 + 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 - 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
+ else if (__pointLocation == INSIDE_TOP_RECTANGLE)
{
- __cropBox.y = __imageBox.y;
+ int temp = __cropBox.width;
+ int width = (__formWidth * (__cropBox.height - (2 * deltaY))) / __formHeight;
+ temp = width - temp;
+ if (__cropBox.height - (2 * deltaY) > (__formHeight * (CROP_RECTANGLE_HEIGHT * 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);
+ }
+ }
}
- if ((__cropBox.x + __cropBox.width + deltaX) > (__imageBox.x + __imageBox.width))
+ else if (__pointLocation == INSIDE_BOTTOM_RECTANGLE)
{
- __cropBox.x = __imageBox.x + __imageBox.width - __cropBox.width;
+ deltaY = deltaY * (-1);
+ int temp = __cropBox.width;
+ int width = (__formWidth * (__cropBox.height - (2 * deltaY))) / __formHeight;
+ temp = width - temp;
+ if (__cropBox.height - (2 * deltaY) > (__formHeight * (CROP_RECTANGLE_HEIGHT * 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);
+ }
+ }
}
- if ((__cropBox.y + __cropBox.height + deltaY) > (__imageBox.y + __imageBox.height))
+ else if (__pointLocation == INSIDE_CROPBOX)
{
- __cropBox.y = __imageBox.y + __imageBox.height - __cropBox.height;
+ 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;
- }
RequestRedraw(false);
__touchStart = currentPosition;
AppLogDebug("EXIT");
int prevWidth = __imageBox.width;
int prevImageboxX = __imageBox.x;
int prevImageBoxY = __imageBox.y;
- int indicatorBarHeight = 0;
-
- if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
+ if (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT)
{
- indicatorBarHeight = 21;
+ __formHeight = Form::GetBounds().height;
+ __formWidth = Form::GetBounds().width;
}
- else
+ else if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
{
- indicatorBarHeight = 60;
+ __formHeight = Form::GetBounds().width;
+ __formWidth = Form::GetBounds().height;
}
- if (__imageWidth > GetClientAreaBounds().width && __imageHeight > GetClientAreaBounds().height)
+ float clientAreaRatio = (GetClientAreaBoundsF().height - FOOTER_PANEL_HEIGHT) / GetClientAreaBoundsF().width;
+ if (__imageWidth >= GetClientAreaBounds().width || __imageHeight > (GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT))
{
- if (__imageHeight > __imageWidth)
+ float imageRatio = __imageHeight / (float) __imageWidth;
+ if (imageRatio < clientAreaRatio)
{
- __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
- __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
- __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
- __imageBox.y = indicatorBarHeight;
+ __imageBox.width = GetClientAreaBounds().width;
+ __imageBox.height = (__imageHeight * __imageBox.width) / __imageWidth;
+ __imageBox.x = GetClientAreaBounds().x;
+ __imageBox.y = GetClientAreaBounds().y + ((GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT) - __imageBox.height) / 2;
}
else
{
- __imageBox.width = GetClientAreaBounds().width;
- __imageBox.height = (GetClientAreaBounds().width * __imageHeight) / __imageWidth;
- __imageBox.x = 0;
- __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
+ __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
+ __imageBox.width = (__imageWidth * __imageBox.height) / __imageHeight;
+ __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
+ __imageBox.y = GetClientAreaBounds().y;
}
}
- else if (__imageWidth > GetClientAreaBounds().width)
- {
- __imageBox.width = GetClientAreaBounds().width;
- __imageBox.height = (__imageHeight * GetClientAreaBounds().width) / __imageWidth;
- __imageBox.x = 0;
- __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
-
- }
- else if (__imageHeight > GetClientAreaBounds().height)
- {
- __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
- __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
- __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
- __imageBox.y = indicatorBarHeight;
- }
else
{
__imageBox.height = __imageHeight;
}
if (__isOrientationChanged == false)
{
- if (__imageHeight >= __imageWidth)
+ if (__imageBox.height > __imageBox.width)
{
- __cropBox.height = __imageBox.height / 2;
- __cropBox.width = __imageBox.width / 2;
- __cropBox.y = __imageBox.y + (__imageBox.height / 4);
- __cropBox.x = __imageBox.x + (__imageBox.width / 4);
+ __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
{
- __cropBox.height = (2 * __imageBox.height) / 3;
- __cropBox.width = (2 * __imageBox.width) / 3;
+ __cropBox.height = (2 *__imageBox.height) / 3;
+ __cropBox.width = (__formWidth * __cropBox.height / __formHeight);
__cropBox.y = __imageBox.y + (__imageBox.height - __cropBox.height) / 2;
__cropBox.x = __imageBox.x + (__imageBox.width - __cropBox.width) / 2;
}
__pCanvas = GetCanvasN();
__pCanvas->SetForegroundColor(CROP_BOX_RECTANGLE_COLOR);
}
+
+void ImageCropForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
+{
+ AppLogDebug(" ENTER");
+ UiApp::GetInstance()->Terminate();
+ AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
__pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
ACTION_ID_CONTEXTMENU_SET_AS);
__pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CROP"), ACTION_ID_FOOTER_BUTTON_CROP);
+ //__pContextMenuMore->AddItem("Rotate Left", ACTION_ID_FOOTER_BUTTON_ROTATE_LEFT);
+ //__pContextMenuMore->AddItem("Rotate Right", ACTION_ID_FOOTER_BUTTON_ROTATE_RIGHT);
}
if (__pGallery->GetItemCount() > 1)
case ACTION_ID_FOOTER_BUTTON_CROP:
{
String filePath;
+ String cropMode = L"auto";
+ //String cropMode = L"auto";
ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
pList->Add(new (std::nothrow) String(filePath));
+ pList->Add(new (std::nothrow) String(cropMode));
pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
}
break;
RotateMode rotateMode = ROTATE_MODE_RIGHT;
__pPresentationModel->SetImageRotateStatus(true);
RotateImage(filePath, rotateMode);
+ AppLog("Manish After Rotate");
+ //__pPresentationModel->SetImageCacheAt(currentIndex, filePath);
+ ImageInfo* pImageInfo = null;
+ pImageInfo->Construct(filePath, null);
+ pImageInfo->ClearBitmap();
+ __pGallery->RefreshGallery(currentIndex, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
__pPresentationModel->RequestImage(filePath);
ContentManager::ScanFile(filePath);
}
}
case ACTION_ID_CONTEXTMENU_HOME:
{
+ String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
+ String cropMode = "fit-to-screen";
ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
- pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
+ pList->Add(new (std::nothrow) String(filePath));
+ pList->Add(new (std::nothrow) String(cropMode));
pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
- __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
+ //__pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
break;
}
case ACTION_ID_CONTEXTMENU_LOCK:
{
+ String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
+ String cropMode = "fit-to-screen";
ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
- pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
+ pList->Add(new (std::nothrow) String(filePath));
+ pList->Add(new (std::nothrow) String(cropMode));
pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
- __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
+ //__pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
break;
}
case ACTION_ID_CONTEXTMENU_CALLER:
case ACTION_ID_CONTEXTMENU_HOME_AND_LOCK:
{
+ String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
+ String cropMode = "fit-to-screen";
ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
- pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
+ pList->Add(new (std::nothrow) String(filePath));
+ pList->Add(new (std::nothrow) String(cropMode));
pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_AND_LOCK_SCREEN_WALLPAPER));
- __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
- break;
+ //__pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
break;
}
if (previousSceneId == IDSCN_IMAGE_CROP && pArgs != null)
{
AppLog("Manish hello");
- String* pFilePath = null;
- pFilePath = static_cast<String*>(pArgs->GetAt(0));
- delete pArgs;
- AppLog("Manish %ls", pFilePath->GetPointer());
String filePath;
- filePath.Append(*pFilePath);
+ filePath = *(static_cast<String*>(pArgs->GetAt(0)));
+ delete pArgs;
+ AppLog("Manish %ls", filePath.GetPointer());
int count = __pPresentationModel->GetFileCount();
- __pPresentationModel->SetImageCacheAt(count, filePath);
+ __pPresentationModel->AddImageCache(filePath);
__pGallery->UpdateGallery();
__pGallery->SetCurrentItemIndex(count);
__pPresentationModel->RequestImage(filePath);
if (pContactId != null && pContactId->GetLength() > 0)
{
LongLong::Parse(*pContactId, lresult);
-
+ String filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
+ String cropMode = "fit-to-screen";
ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+ pList->Add(new (std::nothrow) String(filePath));
+ pList->Add(new (std::nothrow) String(cropMode));
+ pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
+ pList->Add(new (std::nothrow) LongLong(lresult));
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
+ /*ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
pList->Add(new (std::nothrow) LongLong(lresult));
__pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
SceneManager* pSceneManager = SceneManager::GetInstance();
- pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
+ pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);*/
}
}