IMcDisplayEditPasteAoi Method
|
|
Image data previously placed on the the clipboard is pasted
into the ImageToDisplay.
Namespace:
MediaCy.IQL.Display.Viewer
Assembly:
MediaCy.IQL.Display.Viewer (in MediaCy.IQL.Display.Viewer.dll) Version: 10.0.6912.0
SyntaxSub EditPasteAoi (
Optional OptionFlags As mcEditPasteAoiOptionFlags = mcEditPasteAoiOptionFlags.mcepaofUseSettings,
<OptionalAttribute> AlignLeftTop As Object,
Optional BlendPercent As Integer = -1,
Optional BlendOptionFlags As mcViewBlendStyle = mcViewBlendStyle.mvbsUseSettings
)
Parameters
- OptionFlags (Optional)
- Type: MediaCy.IQL.Display.ViewermcEditPasteAoiOptionFlags
These flags (along with the
BlendOptionFlags argument) control the technique used to merge an image the is
in the clipboard with the ImageToDisplay. If the default value of
mcepaofUseSettings is given, then values are determined from the settings saved
by Application.CommandDialogs("Preferences").Pages("PasteOptions"). - AlignLeftTop (Optional)
- Type: SystemObject
If given, this is a LONGPOINT or an array of two
numeric values (x,y) that gives the alignment between the clipboard image and
the ImageToDisplay. It is given as the offset of the left,top of the clipboard
image into the ImageToDisplay; the values may be positive or negative. When the
paste is previewed (OptionFlags mcepaofPreviewThePaste flag is set) then this
offset is used as the intial blending alignment for the preview, otherwise it is
used as the final paste alignment.
If the AlignLeftTop argument is not given, then it is set so that the left,top
of the clipboard image AOI bounds is aligned with the left,top of the
ImageToDisplay AOI bounds. - BlendPercent (Optional)
- Type: SystemInt32
This value is used wherever a blending percentage is
needed both during preview (OptionFlags mcepaofPreviewWithBlend flag is set)
and/or during the apply of the paste (OptionFlags mcepaofApplyWithBlend flag is
set). The BlendPercent specifies the percentage of the clipboard luminance that
is to be blended into the ImageToDisplay; 100% is a full paste. If the default
value of -1 is given, then the blend percentage is taken from the settings
saved by Application.CommandDialogs("Preferences").Pages("PasteOptions"). - BlendOptionFlags (Optional)
- Type: MediaCy.IQL.Display.ViewermcViewBlendStyle
These blending flags are used wherever a
blending is done both during preview (OptionFlags mcepaofPreviewWithBlend flag
is set) and/or during the apply of the paste (OptionFlags mcepaofApplyWithBlend
flag is set). However, whether or not the mcepaofPreviewWithBlend and/or
mcepaofApplyWithBlend option flags are set, the BlendOptionFlags
mvbsMaskBySourceAoi and/or mvbsMaskByDestAoi flags are always honored to
determine if the blend/paste should be restricted to pixels interior to the
source and/or destination AOI(s).
If the default value of mvbsUseSettings is given, then the blend percentage is
taken from the settings saved by
Application.CommandDialogs("Preferences").Pages("PasteOptions").
RemarksEditPasteAoi is a flexible and powerful tool for merging into the
ImageToDisplay an image previously placed on the clipboard by EditCopy or
EditCut. The method has arguments for options that reflect the settings saved
by Application.CommandDialogs("Preferences").Pages("PasteOptions"). In fact the
default behavior for the method is to use the options that were last set in the
Preferences dialog (see Example 1).
The operation is relatively straightforward when the mcepaofPreviewThePaste
OptionFlags is not set (i.e., when no user preview of the paste is called for,
see Example 2). In this case, the clipboard image is just blended into the
ImageToDisplay at the given alignment with the given BlendingOptionFlags (the
actual blending operation is performed with the MOpLib's McGeometry.Blend
method; a 100% blend is a paste). Once the paste is complete, the the
ImageToDisplay AOI is optionally changed based on the mcEditPasteAoiOptionFlags
OptionFlags argument.
Things are a bit more complex when the mcepaofPreviewThePaste OptionFlags is set
(i.e., when a user preview of the paste is called for, see Example 3). In this
case, the method starts the McOvrMgr McBlendTool on the
ImageToDisplay.ImageToolsOverlay McGraphOverlay. The OwningView is made the
working McView for the tool and then the EditPasteAoi method returns. The
actual paste will not occur until the user presses the Enter key or
double-clicks with the left mouse button to indicate that they have finished
placing the image to be pasted. If the user presses the escape key or if some
other tool is invoked, then no paste will ever occur.
EditPasteAoi determines how the user ended the paste preview by monitoring the
IMcGraphOverlayEvents.ToolDeselected event from the McBlendTool. In rare
circumstances you may need to take over this monitoring job in order to do the
paste yourself (e.g., if you wanted to push undo information. Or if you wanted
to use the McGeometry.Blend mcBlendControlFlags mcbcfDoNotScaleSource flag,
which EditPasteAoi does not set.). Setting the OptionFlags
mcEditPasteAoiOptionFlags mcepaofDoNotApplyThePaste bit makes you responsible
for monitoring the ToolDeselected event and doing the actual paste. Example 4
shows how this might be done.
Note |
---|
The pasted image data may have been previously placed there by a call
to the EditCopy or EditCut methods, or it may be a new image created from a
bitmap placed on the clipboard by some other application.
If multiple image clipboard formats are available, their precedence is
mcwcftMcImageAoi, mcwcftMcImageDisplayArea, mcwcftCF_DIB, mcwcftCF_BITMAP, and
then mcwcftCF_ENHMETAFILE. |
Examples
If Not ThisApplication.ActiveWindow.View.Display.IsActionAvailable( mcwaMcImageToPaste) Then
MsgBox "There is no image on the clipboard"
Exit Sub
EndIf
ThisApplication.ActiveWindow.View.Display.EditPasteAoi
Dim PasteOptionFlags As mcEditPasteAoiOptionFlags
PasteOptionFlags = mcepaofAoiAfter_IntersectSrcAndDest
Dim BlendOptionFlags As mcViewBlendStyle
BlendOptionFlags = mvbsMaskBySourceAoi + mvbsMaskByDestAoi
Images(0).Display.EditPasteAoi PasteOptionFlags,,100,BlendOptionFlags
Dim PasteOptionFlags As mcEditPasteAoiOptionFlags
PasteOptionFlags = mcepaofPreviewThePaste + mcepaofPreviewWithBlend + mcepaofAoiAfter_PasteSrcAoi
Dim BlendOptionFlags As mcViewBlendStyle
BlendOptionFlags = mvbsMaskBySourceAoi
Images(0).Display.EditPasteAoi PasteOptionFlags,,50,BlendOptionFlags
Private WithEvents activeOverlay As McGraphOverlay
Private PasteOptions As mcEditPasteAoiOptionFlags
Private PasteBlendStyle As mcViewBlendStyle
Private lPasteBlendFactor As Long
Sub StartEditPasteAoi()
If ActiveWindow Is Nothing Then Exit Sub
If Not ThisApplication.ActiveWindow.View.Display.IsActionAvailable(mcwaMcImageToPaste) Then Exit Sub
PasteOptions = mcepaofPreviewThePaste + mcepaofPreviewWithBlend + mcepaofAoiAfter_PasteSrcAoi
lPasteBlendFactor = 50
PasteBlendStyle = mvbsMaskBySourceAoi
ThisApplication.ActiveWindow.View.Display.EditPasteAoi _
PasteOptions + mcepaofDoNotApplyThePaste, , lPasteBlendFactor, PasteBlendStyle
Set activeOverlay = ThisApplication.ActiveImage.ImageToolsOverlay
End Sub
Private Sub activeOverlay_ToolDeselected(ByVal Overlay As McGraphOverlay, _
ByVal Tool As Object, ByVal GraphObjClassName As String, ByVal TemplateID As Long)
Set activeOverlay = Nothing
Dim activetool As McGraphToolServer
Set activetool = Overlay.activetool
If activetool.ToolClassName <> "McOvrMgr.McBlendTool" Then
Debug.Print "Logic error: activeOverlay_ToolDeselected from some tool other than the McBlendTool."
Exit Sub
End If
Dim lShutdownModeCommandFlags As Long
lShutdownModeCommandFlags = activetool.CommandFlags(mcbtcfEndBlend + mcbtcfAbortBlend)
Dim workingmcview As McView
activetool.CommandFlags = mcvtcfGetWorkingMcView
Set workingmcview = activetool.CommandData
If workingmcview Is Nothing Then
Debug.Print "Blend tool terminated before getting a working McView."
ThisApplication.ActiveWindow.View.Display.BlendingImage = Nothing
Exit Sub
End If
workingmcview.Display.BlendingImage = Nothing
If lShutdownModeCommandFlags = mcbtcfEndBlend Then
Dim Align As LONGPOINT
workingmcview.Display.GetBlendAlignLeftTop Align.x, Align.y
Dim rectBlended As LONGRECT
rectBlended = workingmcview.Display.EditPasteAoiRectangle
If rectBlended.Left < rectBlended.Right Then
workingmcview.ImageToDisplay.UndoStack.Push workingmcview.ImageToDisplay, _
mciuofSaveActiveFrameRange, rectBlended, Empty, "My Paste"
Else
Debug.Print "Attempt to paste an empty target rectangle"
Exit Sub
End If
Dim FinalPasteOptions As mcEditPasteAoiOptionFlags
FinalPasteOptions = PasteOptions And Not mcepaofPreviewThePaste
workingmcview.Display.EditPasteAoi FinalPasteOptions, _
varAlign, lPasteBlendFactor, PasteBlendStyle
ElseIf lShutdownModeCommandFlags = mcbtcfAbortBlend Then
Debug.Print "User aborted the Blend with the Esc key."
Else
Debug.Print "The Blend tool was stopped due to error or some other tool being invoked."
End If
End Sub
See Also