ImageEn, unit imageenproc

TImageEnProc.PasteFromClipboard

TImageEnProc.PasteFromClipboard


Declaration

function PasteFromClipboard(Dest: TIECopyPasteType = iecpAuto; MergeAlpha: Boolean = True; MaintainAspectRatio: Boolean = True; CanStretch: Boolean = True): Boolean;


Description

Pastes an image or layer from the clipboard.

Possible values for Dest:
Item Effect
iecpAuto ImageEn automatically detects the best destination. If an ImageEn layer exists on the clipboard, it is pasted as a new layer. If not, and there is a valid selection, the image is pasted to the selection. Failing that, the image on the clipboard replaces the current image
iecpFullImage The image on the clipboard replaces the existing image
iecpSelection If there is a selection in the associated TImageEnView, the image is pasted to the selection. If there is no selection, it fails
iecpLayer The image or layer on the clipboard is pasted as a new layer in the associated TImageEnView

Other parameters (Relevant only when pasting to a selection):
Parameter Description
MergeAlpha The alpha channel of the pasted bitmap will be merged with the background bitmap. It is only valid if image on the clipboard has been copied from TImageEnView
MaintainAspectRatio If False and pasting to a selection, the inserted image will fill the entire selection. I.e. set to true to maintain the aspect ratio of the original bitmap
CanStretch When pasting to a selection, CanStretch determines whether a source image smaller than the selection is enlarged or maintains its original size (has no effect if MaintainAspectRatio is False, i.e. image will always be stretched)

Result is false if a valid image was not found on the clipboard.

Note:
 When pasting an image from the clipboard, ImageEn favors formats in the following order: Native ImageEn Clipboard format, PNG (for Alpha support), CF_DIB (General support), CF_ENHMETAFILE (Meta-file support)
 All uncompressed DIB formats are handled (1, 4, 8, 15, 16, 24 and 32 bits)
 Color images of 4, 8, 15, 16, 24 or 32 bits are converted to 24 bit. Monochrome images (1 bit) will remain 1 bit
 If the TImageEnProc is attached to a TIEBitmap, TImageEnMView or TImageEnFolderMView then only iecpFullImage is relevant (iecpAuto will have the same effect as iecpFullImage. iecpSelection and iecpLayer will always fail)
 This method supports PdfViewer if Source = iecpAuto


General Example

ImageEnView1.Proc.PasteFromClipboard( iecpAuto );

// Append an image to a TImageEnMView from the clipboard
if IEMView1.Proc.CanPasteFromClipboard() then
begin
  IEMView1.AppendImage( 0, 0 );
  IEMView1.Proc.PasteFromClipboard();
end;


Selection Examples

Source Image



// Paste an image on the clipboard to selection, maintaining the aspect ratio. The image will take the full size of the selection, but maintain its aspect ratio (will not be distored)
ImageEnView1.Proc.PasteFromClipboard( iecpSelection, True );


// Paste an image on the clipboard to selection, maintaining the aspect ratio. If the image is smaller than the selection it will maintain its original dimensions, if it is larger it will be reduced in size to fit within the selection (while maintaining the aspect ratio)
ImageEnView1.Proc.PasteFromClipboard( iecpSelection, True, True, False );


// Paste an image on the clipboard to selection. It will be stretched to the full area of the selection (which may distort the source image)
ImageEnView1.Proc.PasteFromClipboard( iecpSelection, True, False );



See Also

 CanPasteFromClipboard
 PointPasteFromClip
 LayersCreateFromClipboard
 CanCutToClipboard
 CutToClipboard
 CanCopyToClipboard
 CopyToClipboard