Thanks a lot, Lyubo.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
diagram.MeasureUnit = GraphicsUnit.Millimeter;
ruler.Unit = RulerUnit.Millimeter;
}
private void ImageManipulation(string path)
{
var myImage = new BitmapImage(new Uri(path));
var imageWidthPx = myImage.PixelWidth * 96 / myImage.DpiX;
var imageHeightPx = myImage.PixelHeight * 96 / myImage.DpiY;
var imageWidth = GraphicsUnit.Pixel.Convert(imageWidthPx, diagram.MeasureUnit);
var imageHeight = GraphicsUnit.Pixel.Convert(imageHeightPx, diagram.MeasureUnit);
imageNode = diagram.Factory.CreateShapeNode(0, 0, imageWidth, imageHeight);
imageNode.Image = myImage;
imageNode.Shape = Shapes.Rectangle;
imageNode.CustomDraw = CustomDraw.Additional;
imageNode.ImageAlign = ImageAlign.Fit;
var overlayNodeWidth = 200;
var overlayNodeHeight = 200;
overlayNode = diagram.Factory.CreateShapeNode(imageNode.Bounds.Right - overlayNodeWidth,
imageNode.Bounds.Bottom - overlayNodeHeight, overlayNodeWidth, overlayNodeHeight);
overlayNode.Shape = Shapes.Rectangle;
overlayNode.Brush = Brushes.Transparent;
overlayNode.Locked = true;
overlayNode.AttachTo(imageNode, AttachToNode.BottomRight);
}
I used the above code, but the length and width of the displayed imageNode differs from the actual length and width by about 35 mm. Does this code need to be adjusted: var imageWidthPx = myImage.PixelWidth * 96 / myImage.DpiX;
var imageHeightPx = myImage.PixelHeight * 96 / myImage.DpiY;
var imageWidth = GraphicsUnit.Pixel.Convert (imageWidthPx, diagram.MeasureUnit);
var imageHeight = GraphicsUnit.Pixel.Convert (imageHeightPx, diagram.MeasureUnit);