다음을 통해 공유


Ink.Save Method

Ink.Save Method

Converts the Ink object to the specified format, saves it by using the specified compression format, and returns the binary data in a Byte Leave Site array.

Definition

Visual Basic .NET Public Function Save( _
ByVal p As PersistenceFormat, _
ByVal c As CompressionMode _
) As Byte()
C# public byte[] Save(
PersistenceFormat p,
CompressionMode c
);
Managed C++ public: Byte* Save(
PersistenceFormat *p,
CompressionMode *c
) __gc[];

Parameters

p Microsoft.Ink.PersistenceFormat. A memeber of the PersistenceFormat enumeration that indicates the format of the persisted ink.

InkSerializedFormat
0
Specifies ink that is persisted using ISF.

This is the most compact persistent representation of ink. It can be embedded within a binary document format or placed directly on the Clipboard.

Base64InkSerializedFormat
1
Specifies ink that is persisted by encoding the ink serialized format (ISF) as a base64 stream.

This format is provided so ink can be encoded directly in an Extensible Markup Language (XML) or HTML file.

Gif
2
Specifies ink that is persisted by using a Graphics Interchange Format (GIF) file that contains ISF as metadata embedded within the file.

This allows ink to be viewed in applications that are not ink-enabled and maintain its full ink fidelity when it returns to an ink-enabled application. This format is ideal when transporting ink content within an HTML file and making it usable by ink-enabled and ink-unaware applications.

Base64Gif
3
Specifies ink that is persisted by using a base64 encoded fortified GIF.

This format is provided when ink is to be encoded directly in an XML or HTML file with later conversion into an image. A possible use of this is in an XML format that is generated to contain all ink information and used as a way to generate HTML through Extensible Stylesheet Language Transformations (XSLT).

c Microsoft.Ink.CompressionMode. A member of the CompressionMode enumeration that specifies the compression mode of the persisted ink.

Default
0
Provides the optimum balance between saving time and minimizing storage space. This value is useful for the typical application.
Maximum
1
Maximizes compression, thereby minimizing required storage space. The ink takes longer to save. Use this mode when memory is at a premium.
NoCompression
2
Minimizes the time to save the ink. This mode requires more storage space. Use this compressioin mode when compatibility between versions is important.

Return Value

System.Byte[]. Returns the Byte Leave Site array that contains the persisted ink.

Exceptions

ObjectDisposedException Leave Site: The Ink object is disposed.

Remarks

Attempting to save an empty Ink object in GIF format generates an error.

Note: When calling the Save method with the p parameter set to Base64InkSerializedFormat, the return value is a null-terminated byte array. To write the saved ink to an XML file, first remove the last byte from the array before converting the array to an 8-bit Unicode Transformation Format (UTF-8)-encoded string.

Examples

[C#]

This C# example saves the Ink object in the InkCollector object, theInkCollector, in a Byte Leave Site array, theSavedInk. The example later restores the ink in a new Ink object, theNewInk. The ink is stored in Ink Serialized Format (ISF) using the maximum compression.

byte [] theSavedInk =
    theInkCollector.Ink.Save(PersistenceFormat.InkSerializedFormat,
        CompressionMode.Maximum);
// ...
Ink theNewInk = new Ink();
theNewInk.Load(theSavedInk);

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example saves the Ink object in the InkCollector object, theInkCollector, in a Byte Leave Site array, theSavedInk. The example later restores the ink in a new Ink object, theNewInk. The ink is stored in ISF using the maximum compression.

Dim theSavedInk () as Byte = _
    theInkCollector.Ink.Save(PersistenceFormat.InkSerializedFormat, _
        CompressionMode.Maximum)
'...
Dim theNewInk As New Ink()
theNewInk.Load(theSavedInk)

See Also