From: chitta ranjan Date: Sat, 6 Apr 2013 08:50:30 +0000 (+0900) Subject: Crop fit to mode implementation and fixed Jira issue X-Git-Tag: accepted/tizen_2.1/20130425.023641~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=008f125b1080aab47bee79c90bcbc810ca427183;p=apps%2Fosp%2FImageViewer.git Crop fit to mode implementation and fixed Jira issue Change-Id: I9ea10a5c07d5d70615f451c5f1af3c8c6ec190eb Signed-off-by: chitta ranjan --- diff --git a/inc/IvImageCropForm.h b/inc/IvImageCropForm.h index 036d6fd..c04217a 100644 --- a/inc/IvImageCropForm.h +++ b/inc/IvImageCropForm.h @@ -24,6 +24,7 @@ #include #include +#include "IvFileUpdateEventListener.h" using namespace Tizen::Ui; @@ -49,6 +50,7 @@ class ImageCropForm , public Tizen::Ui::IOrientationEventListener , public Tizen::Ui::ITouchEventListener , public Tizen::Ui::Scenes::ISceneEventListener + , public IFileUpdateEventListener { public: ImageCropForm(void); @@ -79,6 +81,8 @@ public: virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId); + virtual void OnFormFileEventOccuered(const int index, const unsigned long eventId); + private: static const int IDA_BUTTON_SAVE = 105; static const int IDA_BUTTON_CW_ROTATION = 102; @@ -87,6 +91,7 @@ private: Tizen::Graphics::Rectangle __cropBox; Tizen::Base::String __sourceFilePath; + Tizen::Base::String __cropMode; Tizen::Graphics::Rectangle __imageBox; Tizen::Media::ImageBuffer __imageBuffer; int __imageHeight; @@ -99,6 +104,10 @@ private: Tizen::Graphics::Point __touchStart; Tizen::Media::ImageFormat __imageFormat; ImageViewerPresentationModel* __pPresentationModel; + int __statusValue; + long long __contentId; + int __formHeight; + int __formWidth; }; #endif /* _IV_IMAGE_CROP_H_ */ diff --git a/inc/IvImageViewerPresentationModel.h b/inc/IvImageViewerPresentationModel.h index 3159505..33a2242 100644 --- a/inc/IvImageViewerPresentationModel.h +++ b/inc/IvImageViewerPresentationModel.h @@ -60,6 +60,7 @@ public: Tizen::Base::String GetFilePathAt(const int index) const; Tizen::Base::Collection::ArrayList* GetImageCache() const; ImageInfo* GetImageCacheAt(const int index) const; + void AddImageCache(const Tizen::Base::String& filePath); void SetImageCacheAt(const int index, const Tizen::Base::String& filePath); int GetFileCount(void) const; diff --git a/src/IvImageCropForm.cpp b/src/IvImageCropForm.cpp index cdb63e8..8b277f9 100644 --- a/src/IvImageCropForm.cpp +++ b/src/IvImageCropForm.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include #include "IvImageCropForm.h" #include "IvImageViewerPresentationModel.h" #include "IvResourceManager.h" @@ -33,6 +35,8 @@ using namespace Tizen::Content; 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; @@ -134,6 +138,7 @@ ImageCropForm::OnInitializing(void) } AddTouchEventListener(*this); AddOrientationEventListener(*this); + __pPresentationModel->AddFileUpdateListener(this); delete pCWRotationButtonBitmap; delete pCCWRotationButtonBitmap; @@ -144,20 +149,101 @@ void ImageCropForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) { AppLogDebug("ENTER pArgs(%x)", pArgs); - String filePath; if (pArgs != null) { - filePath = *(static_cast(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(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(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(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(pEnum->GetCurrent()); + if (pContentId != null) + { + __contentId = pContentId->ToLongLong(); + } + } + + delete pEnum; + delete pArgs; + SetValue(); + } + } + } +// if (pArgs != null) +// { +// __sourceFilePath = *(static_cast(pArgs->GetAt(0))); +// __cropMode = *(static_cast(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) { @@ -167,7 +253,7 @@ ImageCropForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& } Image img; __imageFormat = img.GetImageFormat(__sourceFilePath); - } + }*/ SetValue(); AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult())); } @@ -213,41 +299,140 @@ ImageCropForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) 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 @@ -275,128 +460,396 @@ ImageCropForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graph 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"); @@ -473,49 +926,36 @@ ImageCropForm::SetValue(void) 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; @@ -525,17 +965,17 @@ ImageCropForm::SetValue(void) } 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; } @@ -554,3 +994,10 @@ ImageCropForm::SetValue(void) __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())); +} diff --git a/src/IvImageViewerForm.cpp b/src/IvImageViewerForm.cpp index 3d1d65d..8a830b6 100644 --- a/src/IvImageViewerForm.cpp +++ b/src/IvImageViewerForm.cpp @@ -776,6 +776,8 @@ ImageViewerForm::InitializeContextMenuMore(void) __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) @@ -1419,9 +1421,12 @@ ImageViewerForm::OnActionPerformed(const Control& source, int actionId) 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; @@ -1432,6 +1437,12 @@ ImageViewerForm::OnActionPerformed(const Control& source, int actionId) 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); } @@ -1470,20 +1481,26 @@ ImageViewerForm::OnActionPerformed(const Control& source, int actionId) } 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: @@ -1504,12 +1521,14 @@ ImageViewerForm::OnActionPerformed(const Control& source, int actionId) 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; } @@ -1638,14 +1657,12 @@ ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId, if (previousSceneId == IDSCN_IMAGE_CROP && pArgs != null) { AppLog("Manish hello"); - String* pFilePath = null; - pFilePath = static_cast(pArgs->GetAt(0)); - delete pArgs; - AppLog("Manish %ls", pFilePath->GetPointer()); String filePath; - filePath.Append(*pFilePath); + filePath = *(static_cast(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); @@ -1704,15 +1721,23 @@ ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId, 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);*/ } } diff --git a/src/IvImageViewerPresentationModel.cpp b/src/IvImageViewerPresentationModel.cpp index fc5e1b7..19e455a 100644 --- a/src/IvImageViewerPresentationModel.cpp +++ b/src/IvImageViewerPresentationModel.cpp @@ -310,20 +310,23 @@ ImageViewerPresentationModel::GetImageCacheAt(const int index) const } void -ImageViewerPresentationModel::SetImageCacheAt(const int index, const String& filePath) +ImageViewerPresentationModel::AddImageCache(const String& filePath) { ImageInfo* pImageInfo = null; pImageInfo = new (std::nothrow) ImageInfo(); - AppLog("Manish %d %ls", index, filePath.GetPointer()); - pImageInfo->Construct(filePath, null); - //__pImageCaches->Add(pImageInfo); - int count = __pImageCaches->GetCount(); - AppLog("Manish count %d", count); - //__pImageCaches->SetCapacity(++count); __pImageCaches->Add(pImageInfo); } +void +ImageViewerPresentationModel::SetImageCacheAt(const int index, const String& filePath) +{ + ImageInfo* pImageInfo = null; + pImageInfo->Construct(filePath, null); + pImageInfo->ClearBitmap(); + //__pImageCaches->SetAt(pImageInfo, index); +} + int ImageViewerPresentationModel::GetFileCount(void) const {