Finding CurrentBitmap in the Viewport

2 posts, 0 answers
  1. Khalil
    Khalil avatar
    1 posts
    Member since:
    Oct 2018

    Posted 15 Feb Link to this post

    Hello, I'm trying to find the Parent container of CurrentBitmap inside of CanvasElement.

    I want to ignore the current zoom and window location of the image for a custom control's mouse position relative to the image. Any help would be appreciated.

    Thank you.

  2. Dimitar
    Admin
    Dimitar avatar
    2807 posts

    Posted 19 Feb Link to this post

    Hello Khalil,

    You can use the following approach for this:
    private void CanvasElement_MouseMove(object sender, MouseEventArgs e)
    {
        var canvasElement = radImageEditor1.ImageEditorElement.CanvasElement;
        float x = Math.Abs(canvasElement.ControlBoundingRectangle.X - e.X) * 1f / radImageEditor1.ImageEditorElement.ZoomFactor.Width;
        float y = Math.Abs(canvasElement.ControlBoundingRectangle.Y - e.Y) * 1f / radImageEditor1.ImageEditorElement.ZoomFactor.Height;
     
        PointF positioInImage = new PointF(x, y);
        Console.WriteLine(positioInImage);
    }

    I hope this helps. Should you have any other questions do not hesitate to ask.
     
    Regards,
    Dimitar
    Progress TelerikRadImageEditor for Winforms
Back to Top