Share via


Save Method

Save Method

Converts the ink to the specified InkPersistenceFormat, saves it using the specified InkPersistenceCompressionMode, and returns the binary data in an array of bytes.

Declaration

[C++]

HRESULT Save (
    [in,optional, defaultvalue(IPF_InkSerializedFormat)]
        InkPersistenceFormat persistenceFormat,
    [in,optional, defaultvalue(IPCM_Default)]
        InkPersistenceCompressionMode compressionMode,
    [out, retval] VARIANT *Data
);

[Microsoft® Visual Basic® 6.0]

Public Function Save( _
    [persistenceFormat As InkPersistenceFormat = _
        IPF_InkSerializedFormat], _
    [compressionMode As InkPersistenceCompressionMode = IPCM_Default] _
) As Variant

Parameters

persistenceFormat

[in] The format of the persisted ink, such as ink serialized format (ISF), GIF, and so on.

compressionMode

[in] The compression mode of the persisted ink, such as Maximum compression (minimizes storage space), NoCompression (reduces save-time but disregards storage space), and so on.

Data

[out, retval] Returns the byte array that contains the persisted ink.

For more information about the VARIANT structure, see Using the Automation Library.

Return Value

HRESULT value Description
S_OK Success.
E_POINTER A parameter contained an invalid pointer.
E_INK_EXCEPTION An exception occurred inside the method.
E_INVALIDARG Invalid compression mode.
E_OUTOFMEMORY Cannot allocate byte array.
E_UNEXPECTED Occurs if you attempt to save an empty Ink object in GIF format.

Remarks

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

Note: When calling the Save method with a PersistenceFormat value of Base64InkSerializedFormat, 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 UTF8 encoded string.

In Visual Basic 6.0, storing the ink as a GIF by using a VARIANT as the temporary storage type creates an invalid GIF. You must use a byte array as the temporary storage type instead of a VARIANT.

For instance, instead of:

Dim varTemp As Variant

use:

Dim varTemp() As Byte

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example shows how the ink in the InkCollector can be saved in a Byte array and restored later in a new InkDisp object.

Option Explicit
Dim theInkCollector As InkCollector

Private Sub Command1_Click()
    Dim theSavedInk() As Byte
    theSavedInk = _
        theInkCollector.Ink.Save( _         InkPersistenceFormat.IPF_InkSerializedFormat, _
        InkPersistenceCompressionMode.IPCM_MaximumCompression)
    Dim theNewInk As New InkDisp
    theNewInk.Load theSavedInk
End Sub

Private Sub Form_Load()
    Set theInkCollector = New InkCollector
    theInkCollector.hWnd = Me.hWnd
    theInkCollector.Enabled = True
End Sub

Applies To