SceneImage Class
A raster image (PNG, JPEG, GIF or WebP), stretched to fill a rectangle, or fitted in it (SceneImage.Alignment).
public sealed class SceneImage : SceneElementRemarks
The SVG embeds the bytes of the image as they are. The image and PDF renderers decode them: an image they cannot decode is not drawn.
- Inheritance
SceneElementSceneImage
Constructors
| Name | Description |
|---|---|
| SceneImage(double, double, double, double, ReadOnlyMemory<byte>) | Initializes a new instance of the SceneImage class. |
SceneImage(double, double, double, double, ReadOnlyMemory<byte>)
SceneImage.csInitializes a new instance of the SceneImage class.
Parameters
xdouble- The left edge.
ydouble- The top edge.
widthdouble- The width.
heightdouble- The height.
dataReadOnlyMemory<byte>- The bytes of a PNG, JPEG, GIF or WebP file.
Exceptions
ArgumentExceptiondatadoes not start with the signature of a PNG, JPEG, GIF or WebP file.
Properties
| Name | Description |
|---|---|
| Alignment | Gets or sets how the image keeps its proportions in its rectangle, as the SVG preserveAspectRatio attribute. The default is SceneAspectRatio.None: the image is stretched to fill the rectangle. |
| Data | Gets the bytes of the image file. |
| Height | Gets the height. |
| MediaType | Gets the media type of the image file: image/png, image/jpeg, image/gif or image/webp. |
| Slice | Gets or sets a value that indicates whether the image covers the whole rectangle and is cut to it (slice), rather than fitting in it (meet, the default). It does not apply when SceneImage.Alignment is SceneAspectRatio.None. |
| Width | Gets the width. |
| X | Gets the left edge. |
| Y | Gets the top edge. |
Alignment
SceneImage.csGets or sets how the image keeps its proportions in its rectangle, as the SVG preserveAspectRatio attribute. The default is SceneAspectRatio.None: the image is stretched to fill the rectangle.
public SceneAspectRatio Alignment { get; set; }Property value
Remarks
With another value, the image is scaled by the same factor in both directions, to fit in the rectangle (or to cover it, with SceneImage.Slice), and aligned in it as the value says. The default of SVG is SceneAspectRatio.XMidYMid.
Data
SceneImage.csHeight
SceneImage.csMediaType
SceneImage.csSlice
SceneImage.csGets or sets a value that indicates whether the image covers the whole rectangle and is cut to it (slice), rather than fitting in it (meet, the default). It does not apply when SceneImage.Alignment is SceneAspectRatio.None.
public bool Slice { get; set; }Property value
Width
SceneImage.csMethods
| Name | Description |
|---|---|
| GetMediaType(ReadOnlySpan<byte>) | Gets the media type of an image file from its signature, or null when it is not a PNG, JPEG, GIF or WebP file. |
GetMediaType(ReadOnlySpan<byte>)
SceneImage.csGets the media type of an image file from its signature, or null when it is not a PNG, JPEG, GIF or WebP file.
public static string? GetMediaType(ReadOnlySpan<byte> data)Parameters
dataReadOnlySpan<byte>- The first bytes of the file, at least 12.
Returns
string? The media type, or null.