InkManager.LoadAsync(IInputStream) InkManager.LoadAsync(IInputStream) InkManager.LoadAsync(IInputStream) InkManager.LoadAsync(IInputStream) InkManager.LoadAsync(IInputStream) Method

Definition

Note

For Universal Windows app using Extensible Application Markup Language (XAML), we recommend using InkPresenter and the InkCanvas control instead of InkManager.

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.

public : IAsyncActionWithProgress<ulong> LoadAsync(IInputStream inputStream)
IAsyncActionWithProgress<ulong> LoadAsync(IInputStream inputStream) const;
public IAsyncActionWithProgress<ulong> LoadAsync(IInputStream inputStream)
Public Function LoadAsync(inputStream As IInputStream) As IAsyncActionWithProgress(Of ulong)
Windows.UI.Input.Inking.InkManager.loadAsync(inputStream).done( /* Your success and error handlers */ );

Parameters

inputStream
IInputStream IInputStream IInputStream

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

Returns

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

Examples

The loadStrokes function in this example demonstrates how to:

  • Display a file open screen where the file type is constrained to Graphics Interchange Format (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 Graphics Interchange Format (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();
                            }
                        });
            }
        });
}

Remarks

Embedding the metadata into a Graphics Interchange Format (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

Ink Serialized Format (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.

See also