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 function Load(
    inkdata : byte[]
)

Parameters

  • inkdata
    Type: array<System.Byte[]

    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.

Examples

In this example, saved ink is loaded from a file into the Ink object of an InkOverlay object.

Try 
    ' Ink.Load() must work on a new (unused) ink object.  
    ' Otherwise, an exception is raised.
    mInkOverlay.Enabled = False
    mInkOverlay.Ink = New Ink()
    mInkOverlay.Enabled = True 
    ' FILE_NAME is a class level const 
    Using FS As FileStream = New FileStream(FILE_NAME, FileMode.Open)
        ' read the bytes from the file 
        Dim isf(FS.Length) As Byte
        FS.Read(isf, 0, FS.Length)
        ' and load the Ink object
        mInkOverlay.Ink.Load(isf)
    End Using 
Catch 
    ' handle or rethrow 
End Try
try
{
    // Ink.Load() must work on a new (unused) ink object.  
    // Otherwise, an exception is raised.
    mInkOverlay.Enabled = false;
    mInkOverlay.Ink = new Ink();
    mInkOverlay.Enabled = true;
    // FILE_NAME is a class level const 
    using (FileStream FS = new FileStream(FILE_NAME, FileMode.Open))
    {
        // read the bytes from the file
        byte[] isf = new byte[FS.Length];
        FS.Read(isf, 0, (int)FS.Length);
        // and load the Ink object
        mInkOverlay.Ink.Load(isf);
    }
}
catch 
{
    // handle or rethrow
}

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

Ink Class

Ink Members

Microsoft.Ink Namespace

Ink.Save