ImageEn, unit imageenview

TIEMouseInteract


Declaration

TIEMouseInteractItems = (miZoom, miScroll, miMovingScroll, miSelect, miSelectPolygon, miSelectCircle, miSelectZoom, miSelectMagicWand, miSelectLasso, miSelectChromaKey, miCropTool, miBrushTool, miCloneTool, miRotateTool, miColorFill, miAlphaFill, miMeasureLength, miMeasureRect, miMeasureEllipse, miMeasureAngle, miColorPicker, miRetouchTool);
TIEMouseInteract = set of TIEMouseInteractItems;


Description

Actions that occur when the user moves or clicks the mouse.

Also see TIEMouseInteractLayers, which are layer editing actions that can occur.

VIEW INTERACTIONS:
Value Description
miMovingScroll Moving the mouse over the image (without requiring any clicking) will cause the image to automatically scroll (pan) (see SmoothScrollValue)
miScroll The image can be navigated by clicking with the left mouse button and dragging
miSelectZoom If the user selects an area, it will be automatically zoomed into (and become the new display view). Click and move the mouse to select the zoom rectangle (Notes 1 and 2)
miZoom A left mouse click zooms into the image. A right click zooms out (Note 1)

SELECTION INTERACTIONS:
miSelect A rectangular area can be selected. Click and move the mouse to select the rectangle. miSelect excludes miScroll and miSelectXXX. Simultaneously holding down the Shift key allows the selection of multiple regions. The Alt Key forces the selection to maintain its aspect ratio
miSelectPolygon A polygonal area can be selected. Click (and release) the left mouse button at each point of the polygon, or click and hold the left button and move to specify continuous irregular lines. Simultaneously holding down the Shift key allows the selection of multiple regions. Methods to terminate selection can be specified in SelectionOptions
miSelectCircle A circular/elliptical area can be selected. Click the left button and move the mouse (holding the Alt key will force a circular selection). Simultaneously holding down the Shift key allows the selection of multiple regions
miSelectMagicWand Selects an irregular region of similar colors. Click the left mouse button upon a pixel and similar colors surrounding it are selected (see MagicWandTolerance). Simultaneously holding down the Shift key allows the selection of multiple regions. Also affected by the options: MagicWandMode, MagicWandMaxFilter and MagicWandSize
miSelectLasso A polygonal area can be selected with the mouse. Click the left button and move the mouse to select a continuous irregular region
miSelectChromaKey Selects the subject or background in an image with a solid background color (e.g. a green screen). This is controlled by the options in ChromaKeyOptions

INTERACTIVE EDITING TOOLS
miCropTool Enables the CropTool allowing the user to select a particular area of an image and discards the portions outside the chosen section
miCloneTool Enables the CloneTool allowing the user to click a point on the image and then click elsewhere to clone the content from the original offset
miBrushTool Enables the BrushTool allowing the user to click or drag the image to paint
miRetouchTool Enables the RetouchTool allowing the user to perform fixes on the image with a brush, such as smudging, blurring and inpainting
miRotateTool Enables the RotateTool allowing the user to drag the image to rotate it (Note 3)
miColorFill Enables the FillTool allowing the user to click the image to flood fill with the color ColorFillValue (Tolerance is specified by Tolerance)
miAlphaFill Enables the FillTool allowing the user to click the image to flood fill with the transparency of AlphaFillValue (Tolerance is specified by Tolerance)

MEASUREMENT TOOLS
miMeasureLength Click and drag the cursor to measure distances in the image (use SetScale to set the scale). See demo: Demos\ImageAnalysis\MeasureIt\MeasureIt.dpr (Note 4)
miMeasureRect Click and drag the cursor to measure rectangular areas in the image (use SetScale to set the scale). See demo: Demos\ImageAnalysis\MeasureIt\MeasureIt.dpr (Note 4)
miMeasureEllipse Click and drag the cursor to measure circular areas in the image (use SetScale to set the scale). See demo: Demos\ImageAnalysis\MeasureIt\MeasureIt.dpr (Note 4)
miMeasureAngle Click three points to measure an angle in the image. See demo: Demos\ImageAnalysis\MeasureIt\MeasureIt.dpr

OTHER TOOLS
miColorPicker Changes the cursor to a color picker allowing the user to select a color from the image. Use ColorSelectActions to determine what occurs when the user selects a color. Also see: ResetAfterColorSelect
Notes:
1. Zooming will have only a temporary effect if AutoShrink or AutoStretch is enabled unless you add iedoDisableAutoFitWhenZoom to DisplayOptions. Right-click will have no zoom effect popup menus are specified
2. By default, Zoom selections will be match the aspect ratio (so the image does not stretch inconsistenly). You can disable this by removing iedoMaintainAROnZoomSelect from DisplayOptions
3. Use mlRotateLayers in layer applications, and miRotateTool in other (single layer) applications
4. The units use for measurement are specified by DefaultMeasureUnit (or the OnMeasure event) and the accuracy by MeasureDecimalPlaces


Usage Notes

You can only select one of the following:
miScroll, miSelectZoom, miMeasureLength, miMeasureRect, miMeasureEllipse, miMeasureAngle,
miSelect, miSelectPolygon, miSelectCircle, miSelectMagicWand, miSelectLasso, miSelectChromaKey,
miCropTool, miBrushTool, miCloneTool, miRetouchTool, miRotateTool,
miColorFill, miAlphaFill, miColorPicker

The following are often used in combinations with others:
miZoom, miMovingScroll, mlEditLayerPoints,
mlMoveLayers, mlResizeLayers, mlRotateLayers
miZoom can be used with miScroll, miSelect, miSelectCircle, miSelectZoom, miMovingScroll, miMeasureLength, miMeasureRect, miMeasureEllipse, miMeasureAngle
miMovingScroll can be used with all interactions


Common Usages

Image Display (Drag-scroll and zoom image):
ImageEnView1.MouseInteractGeneral := [ miZoom, miScroll ];

Selection (create, move and resize layers):
ImageEnView1.MouseInteractGeneral := [ miSelect ];

Interactive Editing Tool:
ImageEnView1.MouseInteractGeneral := [ mi*Tool ]; // Always alone

Measure Lengths:
ImageEnView1.MouseInteractGeneral := [ miMeasureLength ]; // Always alone

Measure Rectangular Area:
ImageEnView1.MouseInteractGeneral := [ miMeasureRect ]; // Always alone

Measure Circular Area:
ImageEnView1.MouseInteractGeneral := [ miMeasureEllipse ]; // Always alone

Measure an Angle:
ImageEnView1.MouseInteractGeneral := [ miMeasureAngle ]; // Always alone


Demos

  Demos\Other\MouseInteract\MouseInteract.dpr
  Demos\ImageEditing\CompleteEditor\PhotoEn.dpr
  Demos\Display\SoftPan\SoftPan.dpr (miMovingScroll)
  Demos\ImageEditing\MakeTransparent\MakeTransparent.dpr (miColorPicker)


Examples

// Single left click zoom-in image, single right click zoom-out image, click and
// drag scroll the image (if it is bigger than client area).
ImageEnView1.MouseInteractGeneral := [ miZoom, miScroll ];

// Allow rectangular selections
ImageEnView1.MouseInteractGeneral := [ miSelect ];



// Allow circular selections
ImageEnView1.MouseInteractGeneral := [ miSelectCircle ];



// Allow the user to select the background in an image with a chroma-key background
ImageEnView1.ChromaKeyOptions.Mode := iecSubject;
ImageEnView1.MouseInteractGeneral := [ miSelectChromaKey ];

// Enable measuring of lengths in image (Imperial)
// Set scale of 250 pixels = one inch
ImageEnView1.SetScale( 250, 1, ieuInches );
IEGlobalSettings().DefaultMeasureUnit := ieuInches;
ImageEnView1.Update();
ImageEnView1.MouseInteractGeneral := [ miMeasureLength ];

// Enable measuring of lengths in image (Metric)
// Set 100 pixels = 4cm
ImageEnView1.SetScale( 100, 4, ieuCentimeters );
IEGlobalSettings().DefaultMeasureUnit := ieuCentimeters;
ImageEnView1.Update();
ImageEnView1.MouseInteractGeneral := [ miMeasureLength ];

// Select whole image and allow user to deselect circular regions
With ImageEnView1 do
begin
  SelectionBase := iesbBitmap;
  Select( 0, 0, IEBitmap.Width, IEBitmap.Height );
  ShiftKeyLock := [ iessCtrl_SubFromSel ];
  MouseInteractGeneral := [ miSelectCircle ];
end;

// Fill clicked areas with red
ImageEnView1.FillTool.ColorFillValue := clRed;
ImageEnView1.MouseInteractGeneral := [miColorFill];

// Fill clicked areas with 50% transparency
ImageEnView1.FillTool.AlphaFillValue := 128;
ImageEnView1.MouseInteractGeneral := [miAlphaFill];

// Selecting a color updates all tools
ImageEnView1.FillTool.ColorSelectActions := [ ieccChromaKeyColor, ieccBrushColor, ieccFillColor, ieccRotateBackground, ieccLayerFill ];
ImageEnView1.MouseInteractGeneral := [ miColorPicker ];


// Use miColorPicker to set transparent parts of image

procedure TMainForm.btnSelColorClick(Sender: TObject);
begin
  ImageEnView1.MouseInteractGeneral := [ miColorPicker ];
end;

procedure TMainForm.ImageEnView1UserInteraction(Sender: TObject; Event: TIEUserInteractionEvent; Info: Integer);
var
  c: TColor;
begin
  if Event = ieiColorPickerHover then
  begin
    // Hovering over image - show color in our panel
    pnlCurrentColor.Color := TColor( Info );
  end
  else
  if Event = ieiColorPickerClick then
  begin
    // Clicked image - set this color as transparent in our image
    c := TColor( Info );
    ImageEnView1.Proc.SetTransparentColors( c, c, 0);
  end;
end;


// Smudge the image
ImageEnView1.RetouchTool.RetouchMode := iermSmudge;
ImageEnView1.RetouchTool.SmudgePressure := 15;
ImageEnView1.RetouchTool.Feathering := 3;
ImageEnView1.MouseInteractGeneral := [ miRetouchTool ];




// Apply motion blur to image
ImageEnView1.RetouchTool.RetouchMode := iermMotionBlur ;
ImageEnView1.RetouchTool.MotionBlurSigma := 8;
ImageEnView1.RetouchTool.MotionBlurAngle := 180;
ImageEnView1.RetouchTool.MotionBlurRadius := 10;
ImageEnView1.MouseInteractGeneral := [ miRetouchTool ];




// Use IEVision's Inpainting to remove blemishes in the image
ImageEnView1.RetouchTool.RetouchMode := iermIEVisionInpaint;
ImageEnView1.RetouchTool.InpaintRangeSize := 6;
ImageEnView1.MouseInteractGeneral := [ miRetouchTool ];




See Also

- MouseInteractGeneral
- MouseInteractLayers
- SelectionOptions
- LayerDefaults
- LayersAutoClosePolylines