This project is read-only.

ZoomControl and Adorners

May 15, 2013 at 12:43 PM
Edited May 15, 2013 at 8:55 PM
I hope I get it right. I am using the ZoomControl from WPF Extensions to display an image with pan and zoom support:
<DockPanel Grid.Row="1" x:Name="canvas">            
     <Controls:ZoomControl  x:Name="zoomControl">  
        <Canvas x:Name="canvas">     
             <Image x:Name="imageControl" Stretch="None" />
When the user selects an image with a bowse dialog, I load that image like so:

bmp = new BitmapImage(new Uri(fileName));
this.imageControul.Source = bmp;

I would like to added rectangles\adorners to specific locations (pixel coordinates) on the image the user loaded based on some image processing.
// x,y,width,height are obtained from image processing and are in pixels
var r = new Rectangle();
 r.StrokeThickness = 5;
 r.Stroke = Brushes.Black;
 r.Fill = Brushes.Transparent;
 r.Width = width;
 r.Height = height;

 Canvas.SetLeft(r, y);
 Canvas.SetTop(r, x);

However, the rectangles are not placed in the expected locations? They are the wrong scale and location. How can I translate image pixel coordinates to units I can use in this application