ImageEn, unit ImageEnView

TImageEnView.SetZoneCursorBitmap

TImageEnView.SetZoneCursorBitmap

Declaration

procedure SetZoneCursorBitmap(CursorBitmap: TIEBitmap);

Description

Specify a custom bitmap to use as the cursor.
Pass nil to reset the cursor to the default.

Note:
◼The bitmap must be at least 5x5 and should include an alpha channel
◼The click position (hot spot) will be the center of the bitmap
◼If the cursor flickers excessively, you should set DoubleBuffered := True
◼The cursor does not scale when the image is zoomed

Examples

// Use a PNG as a cursor
cursorBMP := TIEBitmap.Create();
cursorBMP.LoadFromFile( 'D:\MagicWand.png');
ImageEnView1.SetZoneCursorBitmap( cursorBMP );
FreeAndNil( cursorBMP );
ImageEnView1.DoubleBuffered := True;  // to reduce cursor flicker



// Reset the cursor to the default
ImageEnView1.SetZoneCursorBitmap( nil );


// Enable our star stamping mode, which adds a star directly to the image wherever the user clicks
procedure Tfmain.btnAddStampClick(Sender: TObject);
const
  Stamp_Border_Color = clRed;
  Stamp_Border_Width = 2;
  Stamp_Fill_Color   = clYellow;
  Stamp_Shape        = iesStar5;
  Stamp_Width        = 50;
  Stamp_Height       = 50;
var
  cursorBMP: TIEBitmap;
begin
  // Set default style of our layer
  // Note: Can also use OnNewLayer event to customize further
  ImageEnView1.LayerDefaults.Clear();
  ImageEnView1.LayerDefaults.Values[ IELP_BorderColor ] := ColorToString( Stamp_Border_Color );
  ImageEnView1.LayerDefaults.Values[ IELP_BorderWidth ] := IntToStr( Stamp_Border_Width );
  ImageEnView1.LayerDefaults.Values[ IELP_FillColor ] := ColorToString( Stamp_Fill_Color );
  // Easier to use DefaultLayerShape, e.g. ImageEnView1.LayerDefaults.Values[ IELP_Shape ] := IntToStr( Ord( Stamp_Shape ));
  ImageEnView1.LayerDefaults.Values[ IELP_Width ]     := IntToStr( Stamp_Width );
  ImageEnView1.LayerDefaults.Values[ IELP_Height ]    := IntToStr( Stamp_Height );

  // Enable stamp mode, and automatic merging of layers
  ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loStampMode, loAutoMergeNewLayers ];
  IEGlobalSettings().DefaultLayerShape := Stamp_Shape;
  ImageEnView1.MouseInteractLayers := [ mlCreateShapeLayers ];

  // Show a matching star shaped cursor
  cursorBMP := TIEBitmap.Create( Stamp_Width, Stamp_Height );
  try
    cursorBMP.FillWithShape( Stamp_Shape, Stamp_Width, Stamp_Height, Stamp_Border_Color, Stamp_Border_Width, Stamp_Fill_Color, True, False );
    ImageEnView1.SetZoneCursorBitmap( cursorBMP );
  finally
    cursorBMP.Free();
  end;
end;

See Also

◼ZoneCursor
◼AutoCursors
◼Cursor