2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file IvImageCrop.cpp
19 * @brief This is the implementation file for Image Crop.
24 #include "IvImageCropForm.h"
25 #include "IvImageViewerPresentationModel.h"
26 #include "IvResourceManager.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Content;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Io;
35 using namespace Tizen::Media;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
39 static const unsigned int CROP_BOX_RECTANGLE_COLOR = Color32<199, 110, 6>::Value;
40 static const int CROP_BOX_LINE_WIDTH = 5;
42 ImageCropForm::ImageCropForm(void)
45 , __isOrientationChanged(false)
47 , __pCurrentBitmap(null)
48 , __pRectangleBitmap(null)
50 __pointLocation = OUTSIDE_CROPBOX;
53 ImageCropForm::~ImageCropForm(void)
55 if (__pCurrentBitmap != null)
57 delete __pCurrentBitmap;
59 if (__pRectangleBitmap != null)
61 delete __pRectangleBitmap;
63 if (__pCanvas != null)
71 ImageCropForm::Initialize(void)
73 Form::Construct(IDL_FORM_IMAGE_CROP);
74 Form::SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR);
79 ImageCropForm::OnInitializing(void)
83 AppResource* pAppResource = null;
84 Bitmap* pSaveButtonBitmap = null;
85 Bitmap* pCancelButtonBitmap = null;
86 Bitmap* pCWRotationButtonBitmap = null;
87 Bitmap* pCCWRotationButtonBitmap = null;
89 Button* pSaveButton = null;
90 Button* pCancelButton = null;
91 pAppResource = UiApp::App::GetInstance()->GetAppResource();
92 if (pAppResource != null)
94 pSaveButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_SAVE_ICON);
95 pCancelButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CANCEL_ICON);
96 pCWRotationButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CW_ROTATION_ICON);
97 pCCWRotationButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CCW_ROTATION_ICON);
98 __pRectangleBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_RECTANGLE);
101 pPanel = static_cast<Panel*>(GetControl(L"IDC_FOOTER_PANEL"));
104 pSaveButton = static_cast<Button*>(pPanel->GetControl(L"IDC_SAVE_BUTTON"));
105 if (pSaveButton != null)
107 Point startPoint((pSaveButton->GetWidth() - pSaveButtonBitmap->GetWidth()) / 2,
108 (pSaveButton->GetHeight() - pSaveButtonBitmap->GetHeight()) / 2);
109 pSaveButton->SetNormalBitmap(startPoint, *pSaveButtonBitmap);
110 pSaveButton->AddActionEventListener(*this);
111 pSaveButton->SetActionId(IDA_BUTTON_SAVE);
114 pCancelButton = static_cast<Button*>(pPanel->GetControl(L"IDC_CANCEL_BUTTON"));
115 if (pCancelButton != null)
117 Point startPoint((pCancelButton->GetWidth() - pCancelButtonBitmap->GetWidth()) / 2,
118 (pCancelButton->GetHeight() - pCancelButtonBitmap->GetHeight()) / 2);
119 pCancelButton->SetNormalBitmap(startPoint, *pCancelButtonBitmap);
120 pCancelButton->AddActionEventListener(*this);
121 pCancelButton->SetActionId(IDA_BUTTON_CANCEL);
123 Label* pLabel = static_cast<Label*>(pPanel->GetControl(L"IDC_PANEL_LABEL"));
126 SetControlAlwaysOnTop(*pPanel, true);
128 SetControlAlwaysAtBottom(*pLabel, true);
130 AddTouchEventListener(*this);
131 AddOrientationEventListener(*this);
133 delete pSaveButtonBitmap;
134 delete pCancelButtonBitmap;
135 delete pCWRotationButtonBitmap;
136 delete pCCWRotationButtonBitmap;
141 ImageCropForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
143 AppLogDebug("ENTER");
144 String* pFilePath = null;
147 pFilePath = static_cast<String*>(pArgs->GetAt(0));
154 if (pFilePath != null)
156 __sourceFilePath.Append(*pFilePath);
157 result r = __imageBuffer.Construct(pFilePath->GetPointer());
160 __imageWidth = __imageBuffer.GetWidth();
161 __imageHeight = __imageBuffer.GetHeight();
162 __pCurrentBitmap = __imageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_RGB565, BUFFER_SCALING_AUTO);
165 __imageFormat = img.GetImageFormat(__sourceFilePath);
168 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
172 ImageCropForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
174 AppLogDebug("ENTER");
175 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
179 ImageCropForm::OnDraw(void)
181 result r = E_SUCCESS;
182 AppLogDebug("ENTER");
183 if (__pCanvas != null)
185 r = __pCanvas->SetLineWidth(CROP_BOX_LINE_WIDTH);
186 r = __pCanvas->DrawBitmap(Rectangle(__imageBox.x, __imageBox.y, __imageBox.width, __imageBox.height), *__pCurrentBitmap);
187 r = __pCanvas->DrawRectangle(Rectangle(__cropBox.x, __cropBox.y, __cropBox.width, __cropBox.height));
188 r = __pCanvas->DrawBitmap(Rectangle((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2), __cropBox.y - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Top Rectangle
189 r = __pCanvas->DrawBitmap(Rectangle((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Bottom Rectangle
190 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); //Left Rectangle
191 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); //Right Rectangle
192 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2), __cropBox.y - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Top Left Rectangle
193 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2), __cropBox.y - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Top Right Rectangle
194 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Bottom Right Rectangle
195 r = __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Bottom Left Rectangle
202 ImageCropForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
204 SceneManager* pSceneManager = SceneManager::GetInstance();
207 case IDA_BUTTON_CANCEL:
208 pSceneManager->GoBackward(BackwardSceneTransition());
210 case IDA_BUTTON_SAVE:
212 ImageBuffer* pCropBuffer = null;
216 String stringToInsert = L"_";
217 String delimiter = L".";
218 if (__sourceFilePath.IsEmpty() == false)
220 __sourceFilePath.Reverse();
221 __sourceFilePath.IndexOf(delimiter, 0, index);
222 __sourceFilePath.Reverse();
223 __sourceFilePath.Insert(stringToInsert, __sourceFilePath.GetLength() - index - 1);
224 destFilePath.Append(__sourceFilePath);
225 destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
226 while (File::IsFileExist(destFilePath) == true)
229 destFilePath.Clear();
230 destFilePath.Append(__sourceFilePath);
231 destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
233 pCropBuffer = __imageBuffer.CropN(((__cropBox.x - __imageBox.x) * __imageWidth) / __imageBox.width, ((__cropBox.y - __imageBox.y) * __imageHeight) / __imageBox.height,
234 (__cropBox.width * __imageWidth) / __imageBox.width, (__cropBox.height * __imageHeight) / __imageBox.height);
235 pCropBuffer->EncodeToFile(destFilePath, __imageFormat, true, 100);
236 ContentManager::ScanFile(destFilePath);
239 pSceneManager->GoBackward(BackwardSceneTransition());
247 ImageCropForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
249 AppLogDebug("ENTER");
250 __isOrientationChanged = true;
257 ImageCropForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
259 AppLogDebug("ENTER");
260 __touchStart = currentPosition;
261 CheckCurrentPosition(currentPosition);
266 ImageCropForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
268 AppLogDebug("ENTER");
269 int deltaX = currentPosition.x - __touchStart.x;
270 int deltaY = currentPosition.y - __touchStart.y;
271 switch(__pointLocation)
273 case INSIDE_TOP_RECTANGLE:
275 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3)))
277 __cropBox.y += deltaY;
278 __cropBox.height -= deltaY;
283 case INSIDE_BOTTOM_RECTANGLE:
285 if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height)
286 && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
288 __cropBox.height += deltaY;
293 case INSIDE_LEFT_RECTANGLE:
295 if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
297 __cropBox.x += deltaX;
298 __cropBox.width -= deltaX;
303 case INSIDE_RIGHT_RECTANGLE:
305 if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width)
306 && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
308 __cropBox.width += deltaX;
313 case INSIDE_TOP_LEFT_RECTANGLE:
315 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
316 && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
318 __cropBox.y += deltaY;
319 __cropBox.height -= deltaY;
320 __cropBox.x += deltaX;
321 __cropBox.width -= deltaX;
326 case INSIDE_TOP_RIGHT_RECTANGLE:
328 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
329 && (__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
331 __cropBox.width += deltaX;
332 __cropBox.y += deltaY;
333 __cropBox.height -= deltaY;
338 case INSIDE_BOTTOM_LEFT_RECTANGLE:
340 if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3)
341 && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
343 __cropBox.x += deltaX;
344 __cropBox.width -= deltaX;
345 __cropBox.height += deltaY;
350 case INSIDE_BOTTOM_RIGHT_RECTANGLE:
352 if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3)
353 && (__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
355 __cropBox.width += deltaX;
356 __cropBox.height += deltaY;
363 if ((__cropBox.x + deltaX) > __imageBox.x)
365 __cropBox.x += deltaX;
369 __cropBox.x = __imageBox.x;
371 if ((__cropBox.y + deltaY) > __imageBox.y)
373 __cropBox.y += deltaY;
377 __cropBox.y = __imageBox.y;
379 if ((__cropBox.x + __cropBox.width + deltaX) > (__imageBox.x + __imageBox.width))
381 __cropBox.x = __imageBox.x + __imageBox.width - __cropBox.width;
383 if ((__cropBox.y + __cropBox.height + deltaY) > (__imageBox.y + __imageBox.height))
385 __cropBox.y = __imageBox.y + __imageBox.height - __cropBox.height;
393 RequestRedraw(false);
394 __touchStart = currentPosition;
399 ImageCropForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
401 AppLogDebug("ENTER");
402 __pointLocation = OUTSIDE_CROPBOX;
407 ImageCropForm::CheckCurrentPosition(const Point currentPosition)
409 AppLogDebug("ENTER");
410 if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
411 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + (CROP_RECTANGLE_HEIGHT / 2)))
413 __pointLocation = INSIDE_TOP_RECTANGLE;
415 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
416 && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
418 __pointLocation = INSIDE_LEFT_RECTANGLE;
420 else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
421 && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
423 __pointLocation = INSIDE_RIGHT_RECTANGLE;
425 else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
426 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
428 __pointLocation = INSIDE_BOTTOM_RECTANGLE;
430 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
431 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
433 __pointLocation = INSIDE_TOP_LEFT_RECTANGLE;
435 else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
436 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
438 __pointLocation = INSIDE_TOP_RIGHT_RECTANGLE;
440 else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
441 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
443 __pointLocation = INSIDE_BOTTOM_RIGHT_RECTANGLE;
445 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
446 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
448 __pointLocation = INSIDE_BOTTOM_LEFT_RECTANGLE;
450 else if (currentPosition.x > __cropBox.x && currentPosition.x < (__cropBox.x + __cropBox.width) && currentPosition.y > __cropBox.y && currentPosition.y < (__cropBox.y + __cropBox.height))
452 __pointLocation = INSIDE_CROPBOX;
456 __pointLocation = OUTSIDE_CROPBOX;
463 ImageCropForm::SetValue(void)
465 int prevHeight = __imageBox.height;
466 int prevWidth = __imageBox.width;
467 int prevImageboxX = __imageBox.x;
468 int prevImageBoxY = __imageBox.y;
469 int indicatorBarHeight = 0;
471 if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
473 indicatorBarHeight = 21;
477 indicatorBarHeight = 60;
480 if (__imageWidth > GetClientAreaBounds().width && __imageHeight > GetClientAreaBounds().height)
482 if (__imageHeight > __imageWidth)
484 __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
485 __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
486 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
487 __imageBox.y = indicatorBarHeight;
491 __imageBox.width = GetClientAreaBounds().width;
492 __imageBox.height = (GetClientAreaBounds().width * __imageHeight) / __imageWidth;
494 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
497 else if (__imageWidth > GetClientAreaBounds().width)
499 __imageBox.width = GetClientAreaBounds().width;
500 __imageBox.height = (__imageHeight * GetClientAreaBounds().width) / __imageWidth;
502 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
505 else if (__imageHeight > GetClientAreaBounds().height)
507 __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
508 __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
509 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
510 __imageBox.y = indicatorBarHeight;
514 __imageBox.height = __imageHeight;
515 __imageBox.width = __imageWidth;
516 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
517 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2 ;
519 if (__isOrientationChanged == false)
521 if (__imageHeight >= __imageWidth)
523 __cropBox.height = __imageBox.height / 2;
524 __cropBox.width = __imageBox.width / 2;
525 __cropBox.y = __imageBox.y + (__imageBox.height / 4);
526 __cropBox.x = __imageBox.x + (__imageBox.width / 4);
530 __cropBox.height = (2 * __imageBox.height) / 3;
531 __cropBox.width = (2 * __imageBox.width) / 3;
532 __cropBox.y = __imageBox.y + (__imageBox.height - __cropBox.height) / 2;
533 __cropBox.x = __imageBox.x + (__imageBox.width - __cropBox.width) / 2;
538 float temp = __imageBox.x + ((__cropBox.x - prevImageboxX) * __imageBox.width) / (float)prevWidth;
539 __cropBox.x = (temp + 0.5);
540 temp = __imageBox.y + ((__cropBox.y - prevImageBoxY) * __imageBox.height) / (float)prevHeight;
541 __cropBox.y = (temp + 0.5);
542 temp = (__cropBox.height * __imageBox.height) / (float)prevHeight;
543 __cropBox.height = (temp + 0.5);
544 temp = (__cropBox.width * __imageBox.width) / (float)prevWidth;
545 __cropBox.width = (temp + 0.5);
547 __pCanvas = GetCanvasN();
548 __pCanvas->SetForegroundColor(CROP_BOX_RECTANGLE_COLOR);