Skip to main content

Images

  • 2 minutes to read

You can use DiagramImage items to add images to diagrams.

diagram_images

Users can add image items by selecting the corresponding ribbon item on the Insert ribbon page. This item invokes the Insert Picture dialog. To invoke this dialog in code, use the DiagramControl.InsertImage method.

The following code snippet illustrates how to add an image item in code:

DiagramImage image = new DiagramImage { Image = "image.png" };
image.Size = new SizeF(800, 800);
image.Position = new DevExpress.Utils.PointFloat(20, 20);
Diagram.Items.Add(image);

Image items support all operations available to shapes, except for text editing and transformation. The DiagramImage.StretchMode property specifies whether the aspect ratio of the source image is preserved when resizing the diagram item.

The source of the image is specified by the DiagramImage.Image property. The following types are supported: byte[], System.Uri, System.IO.Stream, System.Windows.Media.ImageSource.

The DiagramControl.CustomLoadImage event allows you to implement a custom logic for loading images.

When a diagram image item is selected, the ribbon shows the Image Tools ribbon category that allows users to change the source image, set the stretch mode, flip, rotate or move the selected image item(s) in or out in the Z-order and reset applied changes.

ImageItem Ribbon

See Also