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);
238 ContentManager contentManager;
239 contentManager.Construct();
240 //contentManager.ScanDirectory(Tizen::System::Environment::GetMediaPath(), true, )
241 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
242 pList->Add(new (std::nothrow) String(destFilePath));
243 AppLog("Manish %ls", destFilePath.GetPointer());
244 pSceneManager->GoBackward(BackwardSceneTransition());
252 ImageCropForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
254 AppLogDebug("ENTER");
255 __isOrientationChanged = true;
262 ImageCropForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
264 AppLogDebug("ENTER");
265 __touchStart = currentPosition;
266 CheckCurrentPosition(currentPosition);
271 ImageCropForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
273 AppLogDebug("ENTER");
274 int deltaX = currentPosition.x - __touchStart.x;
275 int deltaY = currentPosition.y - __touchStart.y;
276 switch(__pointLocation)
278 case INSIDE_TOP_RECTANGLE:
280 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3)))
282 __cropBox.y += deltaY;
283 __cropBox.height -= deltaY;
288 case INSIDE_BOTTOM_RECTANGLE:
290 if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height)
291 && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
293 __cropBox.height += deltaY;
298 case INSIDE_LEFT_RECTANGLE:
300 if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
302 __cropBox.x += deltaX;
303 __cropBox.width -= deltaX;
308 case INSIDE_RIGHT_RECTANGLE:
310 if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width)
311 && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
313 __cropBox.width += deltaX;
318 case INSIDE_TOP_LEFT_RECTANGLE:
320 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
321 && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
323 __cropBox.y += deltaY;
324 __cropBox.height -= deltaY;
325 __cropBox.x += deltaX;
326 __cropBox.width -= deltaX;
331 case INSIDE_TOP_RIGHT_RECTANGLE:
333 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
334 && (__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
336 __cropBox.width += deltaX;
337 __cropBox.y += deltaY;
338 __cropBox.height -= deltaY;
343 case INSIDE_BOTTOM_LEFT_RECTANGLE:
345 if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3)
346 && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
348 __cropBox.x += deltaX;
349 __cropBox.width -= deltaX;
350 __cropBox.height += deltaY;
355 case INSIDE_BOTTOM_RIGHT_RECTANGLE:
357 if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3)
358 && (__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
360 __cropBox.width += deltaX;
361 __cropBox.height += deltaY;
368 if ((__cropBox.x + deltaX) > __imageBox.x)
370 __cropBox.x += deltaX;
374 __cropBox.x = __imageBox.x;
376 if ((__cropBox.y + deltaY) > __imageBox.y)
378 __cropBox.y += deltaY;
382 __cropBox.y = __imageBox.y;
384 if ((__cropBox.x + __cropBox.width + deltaX) > (__imageBox.x + __imageBox.width))
386 __cropBox.x = __imageBox.x + __imageBox.width - __cropBox.width;
388 if ((__cropBox.y + __cropBox.height + deltaY) > (__imageBox.y + __imageBox.height))
390 __cropBox.y = __imageBox.y + __imageBox.height - __cropBox.height;
398 RequestRedraw(false);
399 __touchStart = currentPosition;
404 ImageCropForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
406 AppLogDebug("ENTER");
407 __pointLocation = OUTSIDE_CROPBOX;
412 ImageCropForm::CheckCurrentPosition(const Point currentPosition)
414 AppLogDebug("ENTER");
415 if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
416 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + (CROP_RECTANGLE_HEIGHT / 2)))
418 __pointLocation = INSIDE_TOP_RECTANGLE;
420 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (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_LEFT_RECTANGLE;
425 else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
426 && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
428 __pointLocation = INSIDE_RIGHT_RECTANGLE;
430 else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
431 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
433 __pointLocation = INSIDE_BOTTOM_RECTANGLE;
435 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (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_LEFT_RECTANGLE;
440 else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
441 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
443 __pointLocation = INSIDE_TOP_RIGHT_RECTANGLE;
445 else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (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_RIGHT_RECTANGLE;
450 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
451 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
453 __pointLocation = INSIDE_BOTTOM_LEFT_RECTANGLE;
455 else if (currentPosition.x > __cropBox.x && currentPosition.x < (__cropBox.x + __cropBox.width) && currentPosition.y > __cropBox.y && currentPosition.y < (__cropBox.y + __cropBox.height))
457 __pointLocation = INSIDE_CROPBOX;
461 __pointLocation = OUTSIDE_CROPBOX;
468 ImageCropForm::SetValue(void)
470 int prevHeight = __imageBox.height;
471 int prevWidth = __imageBox.width;
472 int prevImageboxX = __imageBox.x;
473 int prevImageBoxY = __imageBox.y;
474 int indicatorBarHeight = 0;
476 if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
478 indicatorBarHeight = 21;
482 indicatorBarHeight = 60;
485 if (__imageWidth > GetClientAreaBounds().width && __imageHeight > GetClientAreaBounds().height)
487 if (__imageHeight > __imageWidth)
489 __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
490 __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
491 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
492 __imageBox.y = indicatorBarHeight;
496 __imageBox.width = GetClientAreaBounds().width;
497 __imageBox.height = (GetClientAreaBounds().width * __imageHeight) / __imageWidth;
499 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
502 else if (__imageWidth > GetClientAreaBounds().width)
504 __imageBox.width = GetClientAreaBounds().width;
505 __imageBox.height = (__imageHeight * GetClientAreaBounds().width) / __imageWidth;
507 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
510 else if (__imageHeight > GetClientAreaBounds().height)
512 __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
513 __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
514 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
515 __imageBox.y = indicatorBarHeight;
519 __imageBox.height = __imageHeight;
520 __imageBox.width = __imageWidth;
521 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
522 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2 ;
524 if (__isOrientationChanged == false)
526 if (__imageHeight >= __imageWidth)
528 __cropBox.height = __imageBox.height / 2;
529 __cropBox.width = __imageBox.width / 2;
530 __cropBox.y = __imageBox.y + (__imageBox.height / 4);
531 __cropBox.x = __imageBox.x + (__imageBox.width / 4);
535 __cropBox.height = (2 * __imageBox.height) / 3;
536 __cropBox.width = (2 * __imageBox.width) / 3;
537 __cropBox.y = __imageBox.y + (__imageBox.height - __cropBox.height) / 2;
538 __cropBox.x = __imageBox.x + (__imageBox.width - __cropBox.width) / 2;
543 float temp = __imageBox.x + ((__cropBox.x - prevImageboxX) * __imageBox.width) / (float)prevWidth;
544 __cropBox.x = (temp + 0.5);
545 temp = __imageBox.y + ((__cropBox.y - prevImageBoxY) * __imageBox.height) / (float)prevHeight;
546 __cropBox.y = (temp + 0.5);
547 temp = (__cropBox.height * __imageBox.height) / (float)prevHeight;
548 __cropBox.height = (temp + 0.5);
549 temp = (__cropBox.width * __imageBox.width) / (float)prevWidth;
550 __cropBox.width = (temp + 0.5);
552 __pCanvas = GetCanvasN();
553 __pCanvas->SetForegroundColor(CROP_BOX_RECTANGLE_COLOR);