Share via


Ink.Load Method

Populates a new Ink object with known binary data.

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)

Syntax

'Declaration
Public Sub Load ( _
    inkdata As Byte() _
)
'Usage
Dim instance As Ink
Dim inkdata As Byte()

instance.Load(inkdata)
public void Load (
    byte[] inkdata
)
public:
void Load (
    array<unsigned char>^ inkdata
)
public void Load (
    byte[] inkdata
)
public function Load (
    inkdata : byte[]
)
Not applicable.

Parameters

  • inkdata
    The byte array that contains the ink data.

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.

Example

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);

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)

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

Ink Class
Ink Members
Microsoft.Ink Namespace
Microsoft.Ink.Ink.Save