Get crop coordinates?

2 posts, 0 answers
  1. Raymond
    Raymond avatar
    24 posts
    Member since:
    Apr 2009

    Posted 21 Sep 2011 Link to this post


    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?

  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 26 Sep 2011 Link to this post

    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.

    the Telerik team

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

  3. DevCraft banner
Back to Top