Image is a content element, which contains an image source and represents an image.
Image is a content element that can be added in the Content collection of a IContainerElement such as RadFixedPage. There are several approaches which you can use to achieve that.
Example 1 shows how to initialize an Image object and add it to a previously defined container.
Example 1: Create image
Image image = new Image(); container.Content.Add(image);
Example 2 demonstrates how to use one of the factory methods of the ContentElementCollection to create a new image and insert it into the respective container.
Example 2: Add image to container
Image image = container.Content.AddImage(); Image imageWithSource = container.Content.AddImage(imageSource);
There are other methods that allow adding an image to a document by passing image size, format and source. They could be used through the FixedContentEditor class.
You can modify an Image element using the properties the class exposes. The properties are listed below.
- ImageSource: Specifies the image source that will be visualized in the Image object.
- Width: The width of the image.
- Height: The height of the image.
- Position: The Position of the image inside the IContainerElement.
The Image class exposes also the GetBitmapSource() method, enabling you to obtain a BitmapSource instance representing the image.
The GetBitmapSource() method is not available in PdfProcessing for Xamarin.
Example 3: Obtain BitmapSource
BitmapSource source = image.GetBitmapSource();