This is a migrated thread and some comments may be shown as answers.

Get crop coordinates?

1 Answer 109 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Raymond
Top achievements
Rank 1
Raymond asked on 21 Sep 2011, 10:13 AM
Hi,

I wonder if there is any way to get the crop coordinates, e.i 850 x 909... Size and position? While using the Crop.

The second thing I want is to set the aspect ratio of the crop rectangle to 2:4. Is this possible?

/Raymond

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 26 Sep 2011, 04:46 PM
Hello Raymond,

You can get the context of the crop command in the following way:

if (this.ImageEditorUI.ImageEditor.ExecutingTool is CropTool)
{
    CropCommandContext context = this.ImageEditorUI.ImageEditor.ExecutingTool.GetContext() as CropCommandContext;
}

The CropCommandContext contains the information about the coordinates of the crop adorner, which will be used if the tool is committed. 
context.X and context.Y are the coordinates of the top left corner of the adorner, whereas
context.Height and context.Width keep the size of the rectangle, which shows the boundaries of the new picture if the tool is commited.

However, these properties are readonly, so you won't be able to set them. In order to fulfill your scenario, you can implement your custom CropTool that sets the aspect ratio you would like to have and restricts the resizing of the adorner if necessary. If you decide on this approach, this article can give you a starting point.

Greetings,
Iva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ImageEditor
Asked by
Raymond
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or