Windows Dev Center

InkManager.LoadAsync | loadAsync method

Asynchronously loads all InkStroke objects from the specified stream to the InkStroke collection that is managed by the InkManager.

Ink data is serialized as Ink Serialized Format (ISF) metadata and embedded into a Graphics Interchange Format (GIF) file.

Syntax


inkManager.loadAsync(inputStream).done( /* Your success and error handlers */ );

Parameters

inputStream

Type: IInputStream

The stream that contains the stroke collection. An IRandomAccessStream (requires IOutputStream) object can be specified instead.

Return value

Type: IAsyncActionWithProgress<UInt64>

The status of the asynchronous operation as the number of bytes fetched. For more information, see ReadAsync method.

Remarks

Embedding the metadata into a GIF file enables ink to be viewed in applications that are not ink-enabled while maintaining full fidelity for ink-enabled applications. This format is ideal for transporting ink content within an HTML file and making it usable by both ink and non-ink applications.

Note  ISF is the most compact persistent representation of ink. It can be embedded within a binary document format or placed directly on the Clipboard while preserving various ink properties such as pressure, width, color, tilt, twist, and so on.

Examples

The loadStrokes function in this example demonstrates how to:

  • Display a file open screen where the file type is constrained to GIF format using the FileOpenPicker object.
  • Set up an input stream through the OpenAsync method.
  • Use the LoadAsync method of an InkManager object (inkManager) to de-serialize the ink data from a GIF file (storageFile).

// Load strokes into an inkManager.
function loadStrokes()
{
    // Set up the file open screen.
    var openPicker = Windows.Storage.Pickers.FileOpenPicker();
    openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary;
    openPicker.fileTypeFilter.replaceAll([".gif"]);

    // Set up the stream.
    var loadStream = null;

    // Asynchronously load the ink data from the stream.
    openPicker.pickSingleFileAsync().done(
        function (file)
        {
            if (null != file)
            {
                file.openAsync(Windows.Storage.FileAccessMode.read).then(
                    function (stream) {
                        loadStream = stream;
                        return inkManager.loadAsync(loadStream);
                    }).done(
                        function()
                        {
                            var strokes = inkManager.getStrokes().length;
                            if (strokes === 0)
                            {
                                statusMessage.innerText = "No strokes in file.";
                            }
                            else
                            {
                                statusMessage.innerText = strokes + " strokes loaded.";
                            }
                            renderAllStrokes();
                            loadStream.close();
                        },
                        function (e)
                        {
                            statusMessage.innerText = "Load failed.";
                            if (loadStream)
                            {
                                // Close the stream if open.
                                loadStream.close();
                            }
                        });
            }
        });
}


Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.UI.Input.Inking
Windows::UI::Input::Inking [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported

Namespace

Windows.UI.Input.Inking
Windows::UI::Input::Inking [C++]

Metadata

Windows.winmd

See also

InkManager
How to load ink data
Responding to pen and stylus input
Ink App sample

 

 

Show:
© 2015 Microsoft