Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/

API Reference

Class

OfficeSvgImageRenderer

Namespace OfficeIMO.Drawing
Assembly OfficeIMO.Core
Modifiers static

Shared dependency-free SVG renderer for projected bitmap/vector images.

Inheritance

  • Object
  • OfficeSvgImageRenderer

Methods

AppendImage 2 overloads
public static StringBuilder AppendImage(StringBuilder builder, String href, Double x, Double y, Double width, Double height, String clipPathId = null, Double clipX = 0, Double clipY = 0, Double clipWidth = 0, Double clipHeight = 0, Double sourceLeft = 0, Double sourceTop = 0, Double sourceWidth = 1, Double sourceHeight = 1, Double rotationDegrees = 0, Boolean flipHorizontal = false, Boolean flipVertical = false, String preserveAspectRatio = null) #
Returns: StringBuilder

Appends an SVG image using normalized source cropping, optional clipping, rotation, and flips.

Parameters

builder System.Text.StringBuilder requiredposition: 0
Markup builder.
href System.String requiredposition: 1
Resolved SVG image reference, such as a data URI.
x System.Double requiredposition: 2
Destination left coordinate.
y System.Double requiredposition: 3
Destination top coordinate.
width System.Double requiredposition: 4
Destination width.
height System.Double requiredposition: 5
Destination height.
clipPathId System.String = null optionalposition: 6
Optional clip-path identifier. Required when source crop should be clipped to the destination rectangle.
clipX System.Double = 0 optionalposition: 7
Clip rectangle left coordinate.
clipY System.Double = 0 optionalposition: 8
Clip rectangle top coordinate.
clipWidth System.Double = 0 optionalposition: 9
Clip rectangle width.
clipHeight System.Double = 0 optionalposition: 10
Clip rectangle height.
sourceLeft System.Double = 0 optionalposition: 11
Normalized source left crop ratio.
sourceTop System.Double = 0 optionalposition: 12
Normalized source top crop ratio.
sourceWidth System.Double = 1 optionalposition: 13
Normalized visible source width ratio.
sourceHeight System.Double = 1 optionalposition: 14
Normalized visible source height ratio.
rotationDegrees System.Double = 0 optionalposition: 15
Clockwise SVG rotation in degrees.
flipHorizontal System.Boolean = false optionalposition: 16
Whether to mirror the image horizontally around the destination center.
flipVertical System.Boolean = false optionalposition: 17
Whether to mirror the image vertically around the destination center.
preserveAspectRatio System.String = null optionalposition: 18
Optional SVG preserveAspectRatio value.

Returns

The supplied builder for call chaining.

public static StringBuilder AppendImage(StringBuilder builder, String href, OfficeImageProjection projection, String clipPathId = null, Nullable<OfficeImagePlacement> clipRectangle = null, String preserveAspectRatio = null) #
Returns: StringBuilder

Appends an SVG image using a shared projection that carries placement, source crop, rotation, and flips.

Parameters

builder System.Text.StringBuilder requiredposition: 0
Markup builder.
href System.String requiredposition: 1
Resolved SVG image reference, such as a data URI.
projection OfficeIMO.Drawing.OfficeImageProjection requiredposition: 2
Shared image projection.
clipPathId System.String = null optionalposition: 3
Optional clip-path identifier. Required when the projection has a source crop.
clipRectangle System.Nullable{OfficeIMO.Drawing.OfficeImagePlacement} = null optionalposition: 4
Optional clip rectangle. Defaults to the projection placement when source crop is used.
preserveAspectRatio System.String = null optionalposition: 5
Optional SVG preserveAspectRatio value.

Returns

The supplied builder for call chaining.

public static StringBuilder AppendImageInViewport(StringBuilder builder, String href, OfficeImageProjection projection, String clipPathId, OfficeImagePlacement viewport, String preserveAspectRatio = null) #
Returns: StringBuilder

Appends an SVG image inside a viewport, using the projection placement as the clip for source-cropped images and the viewport as the clip for uncropped images.

Parameters

builder System.Text.StringBuilder requiredposition: 0
Markup builder.
href System.String requiredposition: 1
Resolved SVG image reference, such as a data URI.
projection OfficeIMO.Drawing.OfficeImageProjection requiredposition: 2
Shared image projection.
clipPathId System.String requiredposition: 3
Clip-path identifier used for the viewport or crop clip.
viewport OfficeIMO.Drawing.OfficeImagePlacement requiredposition: 4
Viewport rectangle that clips uncropped images.
preserveAspectRatio System.String = null optionalposition: 5
Optional SVG preserveAspectRatio value.

Returns

The supplied builder for call chaining.

public static String CreateDataUri(String contentType, Byte[] bytes) #
Returns: String

Builds a data URI image reference from a known-safe content type and image bytes.

Parameters

contentType System.String requiredposition: 0
Image MIME content type.
bytes System.Byte[] requiredposition: 1
Image bytes.

Returns

SVG data URI image reference.

TryCreateDataUri 2 overloads
public static Boolean TryCreateDataUri(String declaredContentType, Byte[] bytes, String fileName, out String dataUri) #
Returns: Boolean

Creates an SVG-safe data URI for image bytes that can either be embedded directly or transcoded through the shared raster decoder.

Parameters

declaredContentType System.String requiredposition: 0
Optional content type from the source package or caller.
bytes System.Byte[] requiredposition: 1
Image bytes.
fileName System.String requiredposition: 2
Optional file name or extension used when metadata is absent or generic.
dataUri System.String@ requiredposition: 3
SVG data URI when the image can be represented in SVG output.

Returns

true when the image can be embedded in SVG output.

public static Boolean TryCreateDataUri(String declaredContentType, Byte[] bytes, String fileName, IOfficeRasterImageCodec imageCodec, out String dataUri) #
Returns: Boolean

Creates an SVG-safe data URI, using an optional shared raster codec when Drawing cannot decode the source format.

Parameters

declaredContentType System.String requiredposition: 0
bytes System.Byte[] requiredposition: 1
fileName System.String requiredposition: 2
imageCodec OfficeIMO.Drawing.IOfficeRasterImageCodec requiredposition: 3
dataUri System.String@ requiredposition: 4
TryGetEmbeddableContentType 2 overloads
public static Boolean TryGetEmbeddableContentType(OfficeImageFormat format, out String contentType) #
Returns: Boolean

Resolves the MIME content type for image formats that can be embedded directly in SVG image elements.

Parameters

format OfficeIMO.Drawing.OfficeImageFormat requiredposition: 0
Detected image format.
contentType System.String@ requiredposition: 1
Resolved MIME content type when supported.

Returns

true when the format can be embedded as an SVG image href.

public static Boolean TryGetEmbeddableContentType(String contentType, out String normalizedContentType) #
Returns: Boolean

Resolves and normalizes a MIME content type when it can be embedded directly in an SVG image element.

Parameters

contentType System.String requiredposition: 0
MIME content type, optionally with parameters.
normalizedContentType System.String@ requiredposition: 1
Canonical MIME content type when supported.

Returns

true when the content type can be embedded as an SVG image href.

public static Boolean TryResolveEmbeddableContentType(String declaredContentType, Byte[] bytes, String fileName, out String contentType) #
Returns: Boolean

Resolves an SVG-embeddable image content type from declared package metadata, image bytes, or a file name.

Parameters

declaredContentType System.String requiredposition: 0
Optional content type from the source package or caller.
bytes System.Byte[] requiredposition: 1
Optional image bytes used for dependency-free signature sniffing.
fileName System.String requiredposition: 2
Optional file name or extension used when metadata is absent or generic.
contentType System.String@ requiredposition: 3
Resolved MIME content type when supported.

Returns

true when the image can be embedded directly in an SVG image href.

WriteImage 2 overloads
public static Void WriteImage(XmlWriter writer, String svgNamespace, String href, Double x, Double y, Double width, Double height, Double rotationDegrees = 0, Nullable<Double> rotationCenterX = null, Nullable<Double> rotationCenterY = null, Boolean flipHorizontal = false, Boolean flipVertical = false, String preserveAspectRatio = null, Action<XmlWriter> writeAdditionalAttributes = null) #
Returns: Void

Writes an SVG image element using shared numeric formatting, optional preserve-aspect behavior, rotation, and flips.

Parameters

writer System.Xml.XmlWriter requiredposition: 0
SVG writer.
svgNamespace System.String requiredposition: 1
SVG namespace URI.
href System.String requiredposition: 2
Resolved SVG image reference, such as a data URI.
x System.Double requiredposition: 3
Destination left coordinate.
y System.Double requiredposition: 4
Destination top coordinate.
width System.Double requiredposition: 5
Destination width.
height System.Double requiredposition: 6
Destination height.
rotationDegrees System.Double = 0 optionalposition: 7
Clockwise SVG rotation in degrees.
rotationCenterX System.Nullable{System.Double} = null optionalposition: 8
Rotation center X coordinate. When omitted, the destination center is used.
rotationCenterY System.Nullable{System.Double} = null optionalposition: 9
Rotation center Y coordinate. When omitted, the destination center is used.
flipHorizontal System.Boolean = false optionalposition: 10
Whether to mirror the image horizontally around the rotation center.
flipVertical System.Boolean = false optionalposition: 11
Whether to mirror the image vertically around the rotation center.
preserveAspectRatio System.String = null optionalposition: 12
Optional SVG preserveAspectRatio value.
writeAdditionalAttributes System.Action{System.Xml.XmlWriter} = null optionalposition: 13
Optional callback for adapter-specific attributes.
public static Void WriteImage(XmlWriter writer, String svgNamespace, String href, OfficeImageProjection projection, String preserveAspectRatio = null, Action<XmlWriter> writeAdditionalAttributes = null, String clipPathId = null, Nullable<OfficeImagePlacement> clipRectangle = null) #
Returns: Void

Writes an SVG image element using a shared projection that carries placement, rotation, and flips.

Parameters

writer System.Xml.XmlWriter requiredposition: 0
SVG writer.
svgNamespace System.String requiredposition: 1
SVG namespace URI.
href System.String requiredposition: 2
Resolved SVG image reference, such as a data URI.
projection OfficeIMO.Drawing.OfficeImageProjection requiredposition: 3
Shared image projection.
preserveAspectRatio System.String = null optionalposition: 4
Optional SVG preserveAspectRatio value.
writeAdditionalAttributes System.Action{System.Xml.XmlWriter} = null optionalposition: 5
Optional callback for adapter-specific attributes.
clipPathId System.String = null optionalposition: 6
Optional clip-path identifier. Required when the projection has a source crop.
clipRectangle System.Nullable{OfficeIMO.Drawing.OfficeImagePlacement} = null optionalposition: 7
Optional clip rectangle. Defaults to the projection placement when source crop is used.
public static Void WriteImageInViewport(XmlWriter writer, String svgNamespace, String href, OfficeImageProjection projection, String clipPathId, OfficeImagePlacement viewport, String preserveAspectRatio = null, Action<XmlWriter> writeAdditionalAttributes = null) #
Returns: Void

Writes an SVG image inside a viewport, using the projection placement as the clip for source-cropped images and the viewport as the clip for uncropped images.

Parameters

writer System.Xml.XmlWriter requiredposition: 0
SVG writer.
svgNamespace System.String requiredposition: 1
SVG namespace URI.
href System.String requiredposition: 2
Resolved SVG image reference, such as a data URI.
projection OfficeIMO.Drawing.OfficeImageProjection requiredposition: 3
Shared image projection.
clipPathId System.String requiredposition: 4
Clip-path identifier used for the viewport or crop clip.
viewport OfficeIMO.Drawing.OfficeImagePlacement requiredposition: 5
Viewport rectangle that clips uncropped images.
preserveAspectRatio System.String = null optionalposition: 6
Optional SVG preserveAspectRatio value.
writeAdditionalAttributes System.Action{System.Xml.XmlWriter} = null optionalposition: 7
Optional callback for adapter-specific attributes.