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)
49 , __pointLocation(OUTSIDE_CROPBOX)
50 , __pPresentationModel(null)
54 ImageCropForm::~ImageCropForm(void)
56 if (__pCurrentBitmap != null)
58 delete __pCurrentBitmap;
60 if (__pRectangleBitmap != null)
62 delete __pRectangleBitmap;
64 if (__pCanvas != null)
71 ImageCropForm::Initialize(void)
73 Form::Construct(IDL_FORM_IMAGE_CROP);
74 Form::SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR);
76 __pPresentationModel = ImageViewerPresentationModel::GetInstance();
82 ImageCropForm::OnInitializing(void)
86 AppResource* pAppResource = null;
87 Bitmap* pSaveButtonBitmap = null;
88 Bitmap* pCancelButtonBitmap = null;
89 Bitmap* pCWRotationButtonBitmap = null;
90 Bitmap* pCCWRotationButtonBitmap = null;
92 Button* pSaveButton = null;
93 Button* pCancelButton = null;
94 pAppResource = UiApp::App::GetInstance()->GetAppResource();
95 if (pAppResource != null)
97 pSaveButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_SAVE_ICON);
98 pCancelButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CANCEL_ICON);
99 pCWRotationButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CW_ROTATION_ICON);
100 pCCWRotationButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CCW_ROTATION_ICON);
101 __pRectangleBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_RECTANGLE);
104 pPanel = static_cast<Panel*>(GetControl(L"IDC_FOOTER_PANEL"));
107 pSaveButton = static_cast<Button*>(pPanel->GetControl(L"IDC_SAVE_BUTTON"));
108 if (pSaveButton != null && pSaveButtonBitmap != null)
110 Point startPoint((pSaveButton->GetWidth() - pSaveButtonBitmap->GetWidth()) / 2,
111 (pSaveButton->GetHeight() - pSaveButtonBitmap->GetHeight()) / 2);
112 pSaveButton->SetNormalBitmap(startPoint, *pSaveButtonBitmap);
113 pSaveButton->AddActionEventListener(*this);
114 pSaveButton->SetActionId(IDA_BUTTON_SAVE);
115 delete pSaveButtonBitmap;
118 pCancelButton = static_cast<Button*>(pPanel->GetControl(L"IDC_CANCEL_BUTTON"));
119 if (pCancelButton != null && pCancelButtonBitmap != null)
121 Point startPoint((pCancelButton->GetWidth() - pCancelButtonBitmap->GetWidth()) / 2,
122 (pCancelButton->GetHeight() - pCancelButtonBitmap->GetHeight()) / 2);
123 pCancelButton->SetNormalBitmap(startPoint, *pCancelButtonBitmap);
124 pCancelButton->AddActionEventListener(*this);
125 pCancelButton->SetActionId(IDA_BUTTON_CANCEL);
126 delete pCancelButtonBitmap;
128 SetControlAlwaysOnTop(*pPanel, true);
129 Label* pLabel = static_cast<Label*>(pPanel->GetControl(L"IDC_PANEL_LABEL"));
132 SetControlAlwaysAtBottom(*pLabel, true);
135 AddTouchEventListener(*this);
136 AddOrientationEventListener(*this);
138 delete pCWRotationButtonBitmap;
139 delete pCCWRotationButtonBitmap;
144 ImageCropForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
146 AppLogDebug("ENTER pArgs(%x)", pArgs);
150 filePath = *(static_cast<String*>(pArgs->GetAt(0)));
155 filePath = __pPresentationModel->GetFilePathAt(0);
158 if (filePath.IsEmpty() == false)
160 __sourceFilePath.Append(filePath);
161 result r = __imageBuffer.Construct(__sourceFilePath.GetPointer());
164 __imageWidth = __imageBuffer.GetWidth();
165 __imageHeight = __imageBuffer.GetHeight();
166 __pCurrentBitmap = __imageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_RGB565, BUFFER_SCALING_AUTO);
169 __imageFormat = img.GetImageFormat(__sourceFilePath);
172 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
176 ImageCropForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
178 AppLogDebug("ENTER");
179 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
183 ImageCropForm::OnDraw(void)
185 result r = E_SUCCESS;
186 AppLogDebug("ENTER");
187 if (__pCanvas != null)
189 r = __pCanvas->SetLineWidth(CROP_BOX_LINE_WIDTH);
190 r = __pCanvas->DrawBitmap(Rectangle(__imageBox.x, __imageBox.y, __imageBox.width, __imageBox.height), *__pCurrentBitmap);
191 r = __pCanvas->DrawRectangle(Rectangle(__cropBox.x, __cropBox.y, __cropBox.width, __cropBox.height));
192 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
193 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
194 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
195 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
196 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
197 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
198 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
199 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
206 ImageCropForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
208 SceneManager* pSceneManager = SceneManager::GetInstance();
211 case IDA_BUTTON_CANCEL:
212 pSceneManager->GoBackward(BackwardSceneTransition());
214 case IDA_BUTTON_SAVE:
216 ImageBuffer* pCropBuffer = null;
220 String stringToInsert = L"_";
221 String delimiter = L".";
222 if (__sourceFilePath.IsEmpty() == false)
224 __sourceFilePath.Reverse();
225 __sourceFilePath.IndexOf(delimiter, 0, index);
226 __sourceFilePath.Reverse();
227 __sourceFilePath.Insert(stringToInsert, __sourceFilePath.GetLength() - index - 1);
228 destFilePath.Append(__sourceFilePath);
229 destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
230 while (File::IsFileExist(destFilePath) == true)
233 destFilePath.Clear();
234 destFilePath.Append(__sourceFilePath);
235 destFilePath.Insert(count, destFilePath.GetLength() - index - 1);
237 pCropBuffer = __imageBuffer.CropN(((__cropBox.x - __imageBox.x) * __imageWidth) / __imageBox.width, ((__cropBox.y - __imageBox.y) * __imageHeight) / __imageBox.height,
238 (__cropBox.width * __imageWidth) / __imageBox.width, (__cropBox.height * __imageHeight) / __imageBox.height);
239 pCropBuffer->EncodeToFile(destFilePath, __imageFormat, true, 100);
240 ContentManager::ScanFile(destFilePath);
243 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
244 pList->Add(new (std::nothrow) String(destFilePath));
245 AppLog("Manish %ls", destFilePath.GetPointer());
246 pSceneManager->GoBackward(BackwardSceneTransition(), pList);
254 ImageCropForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
256 AppLogDebug("ENTER");
257 __isOrientationChanged = true;
264 ImageCropForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
266 AppLogDebug("ENTER");
267 __touchStart = currentPosition;
268 CheckCurrentPosition(currentPosition);
273 ImageCropForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
275 AppLogDebug("ENTER");
276 int deltaX = currentPosition.x - __touchStart.x;
277 int deltaY = currentPosition.y - __touchStart.y;
278 switch(__pointLocation)
280 case INSIDE_TOP_RECTANGLE:
282 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3)))
284 __cropBox.y += deltaY;
285 __cropBox.height -= deltaY;
290 case INSIDE_BOTTOM_RECTANGLE:
292 if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height)
293 && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
295 __cropBox.height += deltaY;
300 case INSIDE_LEFT_RECTANGLE:
302 if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
304 __cropBox.x += deltaX;
305 __cropBox.width -= deltaX;
310 case INSIDE_RIGHT_RECTANGLE:
312 if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width)
313 && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
315 __cropBox.width += deltaX;
320 case INSIDE_TOP_LEFT_RECTANGLE:
322 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
323 && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
325 __cropBox.y += deltaY;
326 __cropBox.height -= deltaY;
327 __cropBox.x += deltaX;
328 __cropBox.width -= deltaX;
333 case INSIDE_TOP_RIGHT_RECTANGLE:
335 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
336 && (__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
338 __cropBox.width += deltaX;
339 __cropBox.y += deltaY;
340 __cropBox.height -= deltaY;
345 case INSIDE_BOTTOM_LEFT_RECTANGLE:
347 if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3)
348 && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
350 __cropBox.x += deltaX;
351 __cropBox.width -= deltaX;
352 __cropBox.height += deltaY;
357 case INSIDE_BOTTOM_RIGHT_RECTANGLE:
359 if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3)
360 && (__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
362 __cropBox.width += deltaX;
363 __cropBox.height += deltaY;
370 if ((__cropBox.x + deltaX) > __imageBox.x)
372 __cropBox.x += deltaX;
376 __cropBox.x = __imageBox.x;
378 if ((__cropBox.y + deltaY) > __imageBox.y)
380 __cropBox.y += deltaY;
384 __cropBox.y = __imageBox.y;
386 if ((__cropBox.x + __cropBox.width + deltaX) > (__imageBox.x + __imageBox.width))
388 __cropBox.x = __imageBox.x + __imageBox.width - __cropBox.width;
390 if ((__cropBox.y + __cropBox.height + deltaY) > (__imageBox.y + __imageBox.height))
392 __cropBox.y = __imageBox.y + __imageBox.height - __cropBox.height;
400 RequestRedraw(false);
401 __touchStart = currentPosition;
406 ImageCropForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
408 AppLogDebug("ENTER");
409 __pointLocation = OUTSIDE_CROPBOX;
414 ImageCropForm::CheckCurrentPosition(const Point currentPosition)
416 AppLogDebug("ENTER");
417 if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
418 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + (CROP_RECTANGLE_HEIGHT / 2)))
420 __pointLocation = INSIDE_TOP_RECTANGLE;
422 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
423 && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
425 __pointLocation = INSIDE_LEFT_RECTANGLE;
427 else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
428 && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
430 __pointLocation = INSIDE_RIGHT_RECTANGLE;
432 else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
433 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
435 __pointLocation = INSIDE_BOTTOM_RECTANGLE;
437 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
438 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
440 __pointLocation = INSIDE_TOP_LEFT_RECTANGLE;
442 else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
443 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
445 __pointLocation = INSIDE_TOP_RIGHT_RECTANGLE;
447 else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
448 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
450 __pointLocation = INSIDE_BOTTOM_RIGHT_RECTANGLE;
452 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
453 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
455 __pointLocation = INSIDE_BOTTOM_LEFT_RECTANGLE;
457 else if (currentPosition.x > __cropBox.x && currentPosition.x < (__cropBox.x + __cropBox.width) && currentPosition.y > __cropBox.y && currentPosition.y < (__cropBox.y + __cropBox.height))
459 __pointLocation = INSIDE_CROPBOX;
463 __pointLocation = OUTSIDE_CROPBOX;
470 ImageCropForm::SetValue(void)
472 int prevHeight = __imageBox.height;
473 int prevWidth = __imageBox.width;
474 int prevImageboxX = __imageBox.x;
475 int prevImageBoxY = __imageBox.y;
476 int indicatorBarHeight = 0;
478 if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
480 indicatorBarHeight = 21;
484 indicatorBarHeight = 60;
487 if (__imageWidth > GetClientAreaBounds().width && __imageHeight > GetClientAreaBounds().height)
489 if (__imageHeight > __imageWidth)
491 __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
492 __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
493 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
494 __imageBox.y = indicatorBarHeight;
498 __imageBox.width = GetClientAreaBounds().width;
499 __imageBox.height = (GetClientAreaBounds().width * __imageHeight) / __imageWidth;
501 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
504 else if (__imageWidth > GetClientAreaBounds().width)
506 __imageBox.width = GetClientAreaBounds().width;
507 __imageBox.height = (__imageHeight * GetClientAreaBounds().width) / __imageWidth;
509 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
512 else if (__imageHeight > GetClientAreaBounds().height)
514 __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
515 __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
516 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
517 __imageBox.y = indicatorBarHeight;
521 __imageBox.height = __imageHeight;
522 __imageBox.width = __imageWidth;
523 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
524 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2 ;
526 if (__isOrientationChanged == false)
528 if (__imageHeight >= __imageWidth)
530 __cropBox.height = __imageBox.height / 2;
531 __cropBox.width = __imageBox.width / 2;
532 __cropBox.y = __imageBox.y + (__imageBox.height / 4);
533 __cropBox.x = __imageBox.x + (__imageBox.width / 4);
537 __cropBox.height = (2 * __imageBox.height) / 3;
538 __cropBox.width = (2 * __imageBox.width) / 3;
539 __cropBox.y = __imageBox.y + (__imageBox.height - __cropBox.height) / 2;
540 __cropBox.x = __imageBox.x + (__imageBox.width - __cropBox.width) / 2;
545 float temp = __imageBox.x + ((__cropBox.x - prevImageboxX) * __imageBox.width) / (float)prevWidth;
546 __cropBox.x = (temp + 0.5);
547 temp = __imageBox.y + ((__cropBox.y - prevImageBoxY) * __imageBox.height) / (float)prevHeight;
548 __cropBox.y = (temp + 0.5);
549 temp = (__cropBox.height * __imageBox.height) / (float)prevHeight;
550 __cropBox.height = (temp + 0.5);
551 temp = (__cropBox.width * __imageBox.width) / (float)prevWidth;
552 __cropBox.width = (temp + 0.5);
554 __pCanvas = GetCanvasN();
555 __pCanvas->SetForegroundColor(CROP_BOX_RECTANGLE_COLOR);