←Select platform

SvgDataUri Class

Summary

Represents a data URI object.

Syntax

C#
VB
Java
Objective-C
C++
public class SvgDataUri
Public Class SvgDataUri
@interface LTSvgDataUri : NSObject
public class SvgDataUri
public ref class SvgDataUri

Remarks

SvgDataUri is a class that handles the data URI uniform resource identifier (URI) scheme for including data in-line in SVG files. The syntax for Data URI is:

data:[<media type\>][;charset=\<character set>][;base64],<data>

Refer to Data URI scheme for more information.

In SVG files, an image element comes in the following form:

<image x="x-position" y="y-position" width="width-value" height="height-value" xlink:href="image-data" />

Where x-position, y-position, width-value and height-value are the optional location and size of the image inside the SVG.

image-data can have one of the following formats:

  • A link to an external resource. For example:

    xlink:href="image.png" or xlink:href="http://server/myimage.png"

  • A data URI that includes the image pixel data embedded inside the SVG:

    xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA ... etc"

Refer to http://www.w3.org/TR/SVG for more information about the SVG image element.

When an SVG document is flattened, all image elements will be embedded in the SVG as data URI elements. This allows the SVG file to be self-contained and passed from a server to a client without relying on any external resources.

Extracting data from a data URI or constructing a new one from raw image data is not supported by the .NET framework directly and the SvgDataUri class contains functionality that allows the user to:

  • Given a data URI value as a string (as in the example above), extract all relevant data such as the media type, character set, encoding and the data itself using the Parse method. Some of these parameters are optional and some come in certain formats and the Parse method can handle all of the features supported by data URI.

  • Encode a data URI object from an image in a file or stream using EncodeFromFile and EncodeFromStream. These methods return a data URI string value that is ready to be inserted into an SVG file.

  • Save the value of an image data URI to a file or stream using DecodeToFile and DecodeToStream using the URI's media type and pixel data. These methods allow the user to extract any embedded image from an SVG document.

Example

For an example, refer to SvgDocument.EnumerateElements

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.Svg Assembly
Click or drag to resize