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

Finding CurrentBitmap in the Viewport

1 Answer 64 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Khalil
Top achievements
Rank 1
Khalil asked on 15 Feb 2019, 06:14 PM

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.

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 19 Feb 2019, 10:37 AM
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
Tags
ImageEditor
Asked by
Khalil
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or