Previous Topic

Next Topic

Book Contents

Book Index

GetImageFromClipboard

Description:

TheGetImageFromClipboard check whether the clipboard contain an image or not. If it does, it will be saved to the specified target file.

Why would you use this function? Imagine you have a Notes application where you want to replace an imbedded image which have been pasted into a document. You want to make sure that you can replace that image with one resized to the same size constrains. By using the Cut- or Copy method in the NotesUIDocument LotusScript class you can easily put the selected element on the clipboard. Then you will use the GetImageFromClipboard function to save the image to a temporary file, and then the GetImageDimension to get the image size. Now that you know the size of the image would will replace, you could use ProcessImage to resize the new image to the old size constraints, and finally import it with NotesUIDocument's Import method.

Declaration:

Declare Function GetImageFromClipboard Lib "VCII2LN.DLL" (_
Byval pstrTargetImageFileName As String, _
iPreferMetaFile As Integer, _
iIncludeAlphaChannel As Integer, _
Byval pstrImportOptions As String) As Integer

Parameters:

Param

Description

pstrTargetImageFileName

The full filename of the saved clipboard image

iPreferMetaFile

Many applications save several image formats when copy data to clipboard. II2LN will by default search for the images in this sequence;
DIB, BMP and ENHANCED METAFILE.

By specifying 1 for this value, you change the search sequence to;
ENHANCED METAFILE, DIB and BMP

Default value is 0

iIncludeAlphaChannel

0 = Don't include alpha channel (transparency information in image)

1 = Include alpha channel, if present in clipboard image.

Default value is 0


Returns:

Code

Description

0

OK, image captured from clipboard and saved to target file

1

Clipboard data isn't recognized as an image

2

Unknown output format

3

Clipboard capture ok, but save to file failed


Usage:

Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim strOutFile As String

strOutFile = "c:\temp\My captured image.psd"

Set uidoc = ws.CurrentDocument
rc = Messagebox("You have SELECTED an image in the current document?", 36, "II2LN")
If rc <> 6 Then Exit Sub
Call uidoc.Cut
iRc = GetImageFromClipboard(strOutFile,0,1,"")
If iRc = 0 Then
Messagebox "All ok, clipboard captured to " & strOutFile
Else
Messagebox "GetImageFromClipboard error" & Cstr(iRc)
End If

Notes:

Note that II2LN will try to create the target image based upon the file type you specify. This means that you will get an JPEG file if you have an file extension of .jpg or .jpeg, and you will get a GIF file if you specify a file extension of .gif. The supported file types are;

JPG, GIF, BMP, PNG, PSD, PSP, TGA and TIFF

Please note that if you want to use the Import trick as described in the introduction above, you should limit the file types to JPG, GIF or BMP, because the Import method in NotesUIDocument only support a very limited number of images.

Introduced in version:

1.5.0.2

See Also

Functions

Identification functions

ImportImage

ImportImageAsResource

AttachImage

ProcessImage

GetImageDimension

GetTIFFFrameCount

GuessImageFormat

GuessImageFormatStrict