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)
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);
117 pCancelButton = static_cast<Button*>(pPanel->GetControl(L"IDC_CANCEL_BUTTON"));
118 if (pCancelButton != null)
120 Point startPoint((pCancelButton->GetWidth() - pCancelButtonBitmap->GetWidth()) / 2,
121 (pCancelButton->GetHeight() - pCancelButtonBitmap->GetHeight()) / 2);
122 pCancelButton->SetNormalBitmap(startPoint, *pCancelButtonBitmap);
123 pCancelButton->AddActionEventListener(*this);
124 pCancelButton->SetActionId(IDA_BUTTON_CANCEL);
126 Label* pLabel = static_cast<Label*>(pPanel->GetControl(L"IDC_PANEL_LABEL"));
129 SetControlAlwaysOnTop(*pPanel, true);
131 SetControlAlwaysAtBottom(*pLabel, true);
133 AddTouchEventListener(*this);
134 AddOrientationEventListener(*this);
136 delete pSaveButtonBitmap;
137 delete pCancelButtonBitmap;
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 pSceneManager->GoBackward(BackwardSceneTransition());
251 ImageCropForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
253 AppLogDebug("ENTER");
254 __isOrientationChanged = true;
261 ImageCropForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
263 AppLogDebug("ENTER");
264 __touchStart = currentPosition;
265 CheckCurrentPosition(currentPosition);
270 ImageCropForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
272 AppLogDebug("ENTER");
273 int deltaX = currentPosition.x - __touchStart.x;
274 int deltaY = currentPosition.y - __touchStart.y;
275 switch(__pointLocation)
277 case INSIDE_TOP_RECTANGLE:
279 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3)))
281 __cropBox.y += deltaY;
282 __cropBox.height -= deltaY;
287 case INSIDE_BOTTOM_RECTANGLE:
289 if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height)
290 && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
292 __cropBox.height += deltaY;
297 case INSIDE_LEFT_RECTANGLE:
299 if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
301 __cropBox.x += deltaX;
302 __cropBox.width -= deltaX;
307 case INSIDE_RIGHT_RECTANGLE:
309 if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width)
310 && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
312 __cropBox.width += deltaX;
317 case INSIDE_TOP_LEFT_RECTANGLE:
319 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
320 && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
322 __cropBox.y += deltaY;
323 __cropBox.height -= deltaY;
324 __cropBox.x += deltaX;
325 __cropBox.width -= deltaX;
330 case INSIDE_TOP_RIGHT_RECTANGLE:
332 if ((__cropBox.y + deltaY) > __imageBox.y && deltaY < (__cropBox.height - (CROP_RECTANGLE_HEIGHT * 3))
333 && (__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3))
335 __cropBox.width += deltaX;
336 __cropBox.y += deltaY;
337 __cropBox.height -= deltaY;
342 case INSIDE_BOTTOM_LEFT_RECTANGLE:
344 if ((__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3)
345 && (__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width - (CROP_RECTANGLE_HEIGHT * 3))
347 __cropBox.x += deltaX;
348 __cropBox.width -= deltaX;
349 __cropBox.height += deltaY;
354 case INSIDE_BOTTOM_RIGHT_RECTANGLE:
356 if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && __cropBox.width + deltaX > (CROP_RECTANGLE_HEIGHT * 3)
357 && (__cropBox.y + __cropBox.height + deltaY) < (__imageBox.y + __imageBox.height) && (__cropBox.height + deltaY) > (CROP_RECTANGLE_HEIGHT * 3))
359 __cropBox.width += deltaX;
360 __cropBox.height += deltaY;
367 if ((__cropBox.x + deltaX) > __imageBox.x)
369 __cropBox.x += deltaX;
373 __cropBox.x = __imageBox.x;
375 if ((__cropBox.y + deltaY) > __imageBox.y)
377 __cropBox.y += deltaY;
381 __cropBox.y = __imageBox.y;
383 if ((__cropBox.x + __cropBox.width + deltaX) > (__imageBox.x + __imageBox.width))
385 __cropBox.x = __imageBox.x + __imageBox.width - __cropBox.width;
387 if ((__cropBox.y + __cropBox.height + deltaY) > (__imageBox.y + __imageBox.height))
389 __cropBox.y = __imageBox.y + __imageBox.height - __cropBox.height;
397 RequestRedraw(false);
398 __touchStart = currentPosition;
403 ImageCropForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
405 AppLogDebug("ENTER");
406 __pointLocation = OUTSIDE_CROPBOX;
411 ImageCropForm::CheckCurrentPosition(const Point currentPosition)
413 AppLogDebug("ENTER");
414 if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
415 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + (CROP_RECTANGLE_HEIGHT / 2)))
417 __pointLocation = INSIDE_TOP_RECTANGLE;
419 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
420 && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
422 __pointLocation = INSIDE_LEFT_RECTANGLE;
424 else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
425 && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
427 __pointLocation = INSIDE_RIGHT_RECTANGLE;
429 else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
430 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
432 __pointLocation = INSIDE_BOTTOM_RECTANGLE;
434 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
435 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
437 __pointLocation = INSIDE_TOP_LEFT_RECTANGLE;
439 else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
440 && currentPosition.y > (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y +(CROP_RECTANGLE_HEIGHT / 2)))
442 __pointLocation = INSIDE_TOP_RIGHT_RECTANGLE;
444 else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
445 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
447 __pointLocation = INSIDE_BOTTOM_RIGHT_RECTANGLE;
449 else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
450 && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
452 __pointLocation = INSIDE_BOTTOM_LEFT_RECTANGLE;
454 else if (currentPosition.x > __cropBox.x && currentPosition.x < (__cropBox.x + __cropBox.width) && currentPosition.y > __cropBox.y && currentPosition.y < (__cropBox.y + __cropBox.height))
456 __pointLocation = INSIDE_CROPBOX;
460 __pointLocation = OUTSIDE_CROPBOX;
467 ImageCropForm::SetValue(void)
469 int prevHeight = __imageBox.height;
470 int prevWidth = __imageBox.width;
471 int prevImageboxX = __imageBox.x;
472 int prevImageBoxY = __imageBox.y;
473 int indicatorBarHeight = 0;
475 if (GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
477 indicatorBarHeight = 21;
481 indicatorBarHeight = 60;
484 if (__imageWidth > GetClientAreaBounds().width && __imageHeight > GetClientAreaBounds().height)
486 if (__imageHeight > __imageWidth)
488 __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
489 __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
490 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
491 __imageBox.y = indicatorBarHeight;
495 __imageBox.width = GetClientAreaBounds().width;
496 __imageBox.height = (GetClientAreaBounds().width * __imageHeight) / __imageWidth;
498 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
501 else if (__imageWidth > GetClientAreaBounds().width)
503 __imageBox.width = GetClientAreaBounds().width;
504 __imageBox.height = (__imageHeight * GetClientAreaBounds().width) / __imageWidth;
506 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
509 else if (__imageHeight > GetClientAreaBounds().height)
511 __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
512 __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
513 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
514 __imageBox.y = indicatorBarHeight;
518 __imageBox.height = __imageHeight;
519 __imageBox.width = __imageWidth;
520 __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
521 __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2 ;
523 if (__isOrientationChanged == false)
525 if (__imageHeight >= __imageWidth)
527 __cropBox.height = __imageBox.height / 2;
528 __cropBox.width = __imageBox.width / 2;
529 __cropBox.y = __imageBox.y + (__imageBox.height / 4);
530 __cropBox.x = __imageBox.x + (__imageBox.width / 4);
534 __cropBox.height = (2 * __imageBox.height) / 3;
535 __cropBox.width = (2 * __imageBox.width) / 3;
536 __cropBox.y = __imageBox.y + (__imageBox.height - __cropBox.height) / 2;
537 __cropBox.x = __imageBox.x + (__imageBox.width - __cropBox.width) / 2;
542 float temp = __imageBox.x + ((__cropBox.x - prevImageboxX) * __imageBox.width) / (float)prevWidth;
543 __cropBox.x = (temp + 0.5);
544 temp = __imageBox.y + ((__cropBox.y - prevImageBoxY) * __imageBox.height) / (float)prevHeight;
545 __cropBox.y = (temp + 0.5);
546 temp = (__cropBox.height * __imageBox.height) / (float)prevHeight;
547 __cropBox.height = (temp + 0.5);
548 temp = (__cropBox.width * __imageBox.width) / (float)prevWidth;
549 __cropBox.width = (temp + 0.5);
551 __pCanvas = GetCanvasN();
552 __pCanvas->SetForegroundColor(CROP_BOX_RECTANGLE_COLOR);