Image inline elements are represented by instances of the NImageInline class. The following code shows how to create a paragraph that contains a bitmap image:
Creating Raster Image Inlines |
Copy Code
|
---|---|
NSection section = new NSection(); NParagraph paragraph = new NParagraph(); paragraph.Inlines.Add(new NTextInline("Tablet image: ")); NImageInline imageInline = new NImageInline(); imageInline.Image = NImage.FromFile("C:\\tablet.jpg")); paragraph.Inlines.Add(imageInline); section.Blocks.Add(paragraph); m_RichText.Content.Sections.Clear(); m_RichText.Content.Sections.Add(section); |
This code will result in the following text output:
By default, the image inline will have a size equal to the contained image width and height. If you want to stretch the image so that it looks smaller or bigger you can modify its PreferredWidth and PreferredHeight properties. For example:
Setting PreferredWidth and PreferredHeight |
Copy Code
|
---|---|
rasterImage.PreferredHeight = new NMultiLength(ENMultiLengthUnit.Dip, 100); rasterImage.PreferredWidth = new NMultiLength(ENMultiLengthUnit.Dip, 100); |
Tells the control to scale the image so that its width and height become 100 dips.