VegaRise.NET
Back to DOM

ImageClass

Definition

Namespace
DOM.Elements.Graphics
Assembly
DOM.dll

Represents an image element that can be inserted into a document.

Remarks

extends and provides loading, sizing, positioning, and export facilities for raster images (PNG, JPEG, GIF, BMP, TIFF). It corresponds to a <w:drawing> element (inline or anchored) in WordprocessingML and to <img> in HTML. Image Graphic Images can be loaded from a file, stream, or an existing . Their intrinsic dimensions are captured during load so that the document layout can preserve aspect ratio unless explicitly overridden via . Image SetDimensions

Examples

csharp
1// 1. Load from a file and place at a fixed position
2var img = new Image("logo.png");
3img.SetPosition(100, 200, Units.pt);
4img.SetDimensions(300, 200, Units.pt);
5doc.AddImage(img);
6
csharp
1// 2. Load from a stream and let size default to native resolution
2using var stream = File.OpenRead("chart.png");
3var img = new Image(stream);
4doc.AddImage(img);
5
csharp
1// 3. Load from a System.Drawing.Image
2using var sysImg = System.Drawing.Image.FromFile("photo.jpg");
3var img = new Image(sysImg);
4img.SetDimensions(400, 300, Units.pt);
5doc.AddImage(img);
6
csharp
1// 4. Re-export the image as JPEG with 85% quality
2var img = new Image("logo.png");
3img.ExportToFile("logo.jpg", ImageType.jpeg, lossy: 85);
4

Constructors

Image()

Initialises a new empty instance. Image

Image(string imagePath)

Initialises a new instance from a file path. Image

Image(Stream imageStream)

Initialises a new instance from a stream. Image

Image(Image sysImage)

Initialises a new instance from an existing . Image, Image

Properties

ImageContent

Gets or sets the image payload (Base64 encoded content and metadata).

Type

Gets or sets the detected image type (PNG, JPEG, GIF, BMP, TIFF, etc.).

Methods

Creates a deep clone of this image element.

Exports the current image to a file, optionally re-encoding it to a different format.

Exports the current image to a stream, optionally re-encoding it to a different format.

Loads image data from a file into this instance.

Loads image data from a stream into this instance.

VegaRise.NET

Sign In

Welcome back. Please sign in to your account.

Forgot password?
or

Don't have an account? Create an account

By signing in, you agree to our Terms of Service and Privacy Policy.