ZoomControl and Adorners

May 15, 2013 at 11:43 AM
Edited May 15, 2013 at 7: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" />
        </Canvas> 
     </Controls:ZoomControl>
</DockPanel>
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);

 canvas.Children.Add(r);
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

Thanks,

John