ReadImageFromClipboard Method

NI Vision for Visual Basic

ReadImageFromClipboard Method

Syntax

CWIMAQVision.ReadImageFromClipboard DestImage, ClipboardHasImage [, ColorPalette]

Return Type

Long

On success, this method returns 0. On failure, this method returns a negative number.

Purpose

Reads an image from the clipboard.

Remarks

Use this method with image types U8 and RGB32.

Parameters

DestImage As CWIMAQImage

The image to copy the clipboard image into.

ClipboardHasImage As Boolean

On return, True if the clipboard contains an image.

ColorPalette As Variant

[Optional] On return, that color palette associated with the 8-bit clipboard image. If there is no palette associated with the image, the method fills in a grayscale palette.

Example

Private Sub Run_Click()
    Dim HasImage As Boolean
    'Copy the image in clipboard to the image in viewer1. Also, copy the palette from the
    'clipboard. If the clipboard did not contain an image, raise an error.
    CWIMAQVision1.ReadImageFromClipboard CWIMAQViewer1.Image, HasImage, CWIMAQViewer1.Palette
    If Not HasImage Then
        'There was no image on the clipboard, so raise an error (the error number is arbitrary)
        Err.Raise vbObjectError + 1981, "Run_Click", "The clipboard does not contain an image."
    End If
End Sub

See Also

WriteImageToClipboard