Share via


Ink.Save Method (PersistenceFormat, CompressionMode)

Converts the Ink object to the specified format, saves it by using the specified compression format, and returns the binary data in a Byte array.

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

Syntax

'Declaration
Public Function Save ( _
    p As PersistenceFormat, _
    c As CompressionMode _
) As Byte()
'Usage
Dim instance As Ink 
Dim p As PersistenceFormat 
Dim c As CompressionMode 
Dim returnValue As Byte()

returnValue = instance.Save(p, c)
public byte[] Save(
    PersistenceFormat p,
    CompressionMode c
)
public:
array<unsigned char>^ Save(
    PersistenceFormat p, 
    CompressionMode c
)
public function Save(
    p : PersistenceFormat, 
    c : CompressionMode
) : byte[]

Parameters

Return Value

Type: array<System.Byte[]
The Byte array that contains the persisted ink.

Remarks

Attempting to save an empty Ink object in Gif format generates an error.

Note

When calling the Save method with the p parameter set toBase64InkSerializedFormat, the return value is a null-terminated byte array. To write the saved ink to an XML file, first remove the last byte from the array before converting the array to an 8-bit Unicode Transformation Format (UTF-8)-encoded string.

Examples

In this example, the Ink object of an InkOverlay object is saved to a file in Gif format. The CompressionMode is set to NoCompression.

Try 
    ' FILE_NAME is a class level const 
    Using FS As FileStream = New FileStream(FILE_NAME, FileMode.Create)
        Dim isf As Byte() = mInkOverlay.Ink.Save(PersistenceFormat.Gif, CompressionMode.NoCompression)
        FS.Write(isf, 0, isf.Length)
    End Using 

Catch 
    ' handle or rethrow 
End Try
try
{
    // FILE_NAME is a class level const 
    using (FileStream FS = new FileStream(FILE_NAME, FileMode.Create))
    {
        byte[] isf = mInkOverlay.Ink.Save(PersistenceFormat.Gif, CompressionMode.NoCompression);
        FS.Write(isf, 0, isf.Length);
    }
}
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

Save Overload

Microsoft.Ink Namespace

Load

PersistenceFormat

CompressionMode