ImageEn, unit imageenview

TImageEnView.SelectionMaskDepth

TImageEnView.SelectionMaskDepth


Declaration

property SelectionMaskDepth: Integer;


Description

The SelectionMaskDepth property allows the specification of the selection depth in bits.
The default is 1 bit which means a pixel has two states "unselected" (0) or "selected" (1).
If the setting is 8 (8 bit), a pixel can be "unselected" (0), "semi-selected" (1 to 254), or "fully selected" (255). This allows creating soft or feathered selections.

Note:
SelectionOptions=iesoFilled is not supported when the SelectionMaskDepth = 8
Changing SelectionMaskDepth, resets the selection


Examples

// Apply negative effect at 50% intensiry
ImageEnView1.SelectionMaskDepth := 8;
ImageEnView1.SelectionIntensity := 128;  // 128=50% selected
ImageEnView1.Select( 10, 10, 100, 100 );
ImageEnView1.Proc.Negative();




// Make a gradient selection (increasing from unselected to fully selected along height of image)
// Then convert selection to gray scale
ImageEnView1.Deselect();
ImageEnView1.SelectionMaskDepth := 8;
for Y := 0 to ImageEnView1.IEBitmap.Height - 1 do
  for X := 0 to ImageEnView1.IEBitmap.Width - 1 do
  begin
    selIntensity := Round( Y / ImageEnView1.IEBitmap.Height * 255 );
    ImageEnView1.SelectionMask.SetPixel( X, Y, selIntensity );
  end;
ImageEnView1.SelectCustom;
ImageEnView1.Proc.ConvertToGray();
ImageEnView1.Deselect();




// Turn image into chessboard pattern
ImageEnView1.Deselect();
ImageEnView1.SelectionMaskDepth := 1;
for Y := 0 to ImageEnView1.IEBitmap.Height - 1 do
  for X := 0 to ImageEnView1.IEBitmap.Width - 1 do
  begin
    if x div SQUARE_SIZE mod 2 = 0 then
      sel := True
    else
      sel := False;
    if y div SQUARE_SIZE mod 2 = 0 then
      sel := not sel;

    if sel then
      ImageEnView1.SelectionMask.SetPixel( X, Y, 1 )
    else
      ImageEnView1.SelectionMask.SetPixel( X, Y, 0 );
  end;
ImageEnView1.SelectCustom;
ImageEnView1.Proc.ConvertToGray();
ImageEnView1.Deselect();


See Also

SelectionMask
SelectionIntensity