ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 rubber stamping shapes
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

email_toan

USA
26 Posts

Posted - Apr 21 2025 :  10:18:07  Show Profile  Reply
I'd like to allow users to add shape layers, however I'd like to temporarily change the mouse cursor to the selected shape. That way, users can preview and position the shape prior to "rubber stamping" the shape layer. It is similar to Photoshop Brush where the cursor changes to a circle.

I was thinking of creating a temporary layer and responding to mousemove event, but wanted to know if there is an easier way or if the feature already exists.

Any help would be appreciated.

xequte

38948 Posts

Posted - Apr 21 2025 :  21:50:11  Show Profile  Reply
Yes, you can do it like this:

procedure Tfmain.btnStarStampClick(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
  // Add a star every time the layer clicks on the image
  // Note: Can also use OnNewLayer event to customize layer

  // Set default styles
  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... 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 );

  ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loStampMode ];
  IEGlobalSettings().DefaultLayerShape := Stamp_Shape;
  ImageEnView1.MouseInteractLayers := [mlCreateShapeLayers];

  // Show a matching star shaped cursor
  cursorBMP := TIEBitmap.Create( Stamp_Width, Stamp_Height, clWhite, 0 {Transparent background} );
  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;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: