Partager via


Ink.Load Method

Ink.Load Method

Populates a new Ink object with known binary data.

Definition

Visual Basic .NET Public Sub Load( _
ByVal inkdata() As Byte _
)
C# public void Load(
byte[] inkdata
);
Managed C++ public: void Load(
Byte *inkdata __gc[]
);

Parameters

inkdata System.Byte[]. The byte array that contains the ink data.

Exceptions

ObjectDisposedException Leave Site: The Ink object is disposed.

Remarks

You can load ink only into a new, empty Ink object—an Ink object that has neither collected any Stroke object nor has any attached properties. If you try to load ink into an Ink object that has collected strokes or attached properties, even if the strokes or properties have been deleted from the Ink object, an exception is thrown. This occurs because of how the Id properties are assigned. A Stroke object is assigned a unique Id property, and this Id property is not reused, even if the Stroke object has been deleted from an Ink object. This means that if an Ink object contained a Stroke with an Id property of 1 and you deleted the Stroke and loaded different ink data into this Ink object, the Id property for any new Stroke object would have to start at 2. Tracking this across numerous Ink objects could lead to errors and is therefore not allowed.

Note: If you do attempt to load ink into a an Ink object that is not empty, all data in the Ink object, including any CustomStrokes or ExtendedProperties, is lost when you call the Load method.

The Save method allows you to persist the ink in GIF format, which consists of an array of byte data. The GIF persistence format is specified in the PersistenceFormat enumeration type. After you have the array of byte data, you can load it into another Ink object. This means that you can load GIF-compatible byte array data into another Ink object in the same way as if you had called the Save method and received a byte array that was not in GIF format.

Note: You cannot create an image, persist that image as a byte array, and then load that byte array into another Ink object. This is because after you load byte array data as a GIF, Microsoft® Windows® XP Tablet PC Edition cannot control the format of that data; therefore, after you persist the image into a byte array again, you cannot call Load on that data.

Examples

[C#]

This C# example saves the ink in an InkCollector object, theInkCollector, into a byte array, theSavedInk. The example later restores the saved ink in a new Ink object, theNewInk.

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 in an InkCollector object, theInkCollector, into a byte array, theSavedInk. The example later restores the saved ink in a new Ink object, theNewInk.

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

See Also