Udostępnij za pośrednictwem


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:
 virtual IAsyncActionWithProgress<unsigned long long> ^ LoadAsync(IInputStream ^ inputStream) = LoadAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncActionWithProgress<uint64_t> LoadAsync(IInputStream const& inputStream);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncActionWithProgress<ulong> LoadAsync(IInputStream inputStream);
function loadAsync(inputStream)
Public Function LoadAsync (inputStream As IInputStream) As IAsyncActionWithProgress(Of ULong)

Parameters

inputStream
IInputStream

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

Returns

IAsyncActionWithProgress<UInt64>

Windows.Foundation.IAsyncActionWithProgress<unsigned long long>

IAsyncActionWithProgress<uint64_t>

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

Implements

Attributes

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.

Applies to

See also