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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Using BrushTool with code only (no mouse used)

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Sybren Posted - Sep 18 2018 : 14:01:26
I'm trying to repaint an image using the BrushTool possibilities. This way I can create a kind of cool graffiti effect. Scrolling over the 'brush' forum topics, I couldn't find an answer.

The code I'm currently using is based on program code to actually move the mouse between two points (I can't seem the mouse to continuously move over more than 2 points), while 'pressing' the left mouse button:

procedure TForm1.Button1Click(Sender: TObject);
var
  i, j: integer;
  Pt, St: TPoint;
begin
   { Define the starting point = left-top corner of image 'RightImg' }
   { 10 pixels from the left-top edges }
   St.x := RightImg.Left + 10;
   St.y := RightImg.Top + 10; 
   { draw 25 random brush lines within the boundaries of the image }
   for j := 1 to 25 do 
   begin 
     { required to draw one brush line }
     for i := 1 to 2 do
     begin  
      { effectively 10 pixels from the right-bottom edges }
      Pt.X := St.X + random(RightImg.Width - 20);
      Pt.Y := St.Y + random(RightImg.Height - 20);
      { Convert Pt to screen coordinates relative to the 65535 mouse-steps across the screen }
      Pt := ClientToScreen(Pt);
      Pt.x := Round(Pt.x * (65535 / Screen.Width));
      Pt.y := Round(Pt.y * (65535 / Screen.Height));
      { Simulate the mouse move }
      Mouse_Event(MOUSEEVENTF_ABSOLUTE or
                  MOUSEEVENTF_MOVE,
                  Pt.x, Pt.y, 0, 0);
      { Simulate the left mouse button down }
      if i = 1 then Mouse_Event(MOUSEEVENTF_ABSOLUTE or
                  MOUSEEVENTF_LEFTDOWN,
                  Pt.x, Pt.y, 0, 0);
      { Simulate the left mouse button up }
      if i = 2 then Mouse_Event(MOUSEEVENTF_ABSOLUTE or
                  MOUSEEVENTF_LEFTUP,
                  Pt.x, Pt.y, 0, 0);
    end; 
    { optional when 'Application.ProcessMessages' is used }
    RightImg.Update;
    { optional: to watch the painting take place }
    Application.ProcessMessages; 
  end;
end;

Additional settings to activate the BrushTool:

  RightImg.BrushTool.BrushShape := iecsCircle;
  RightImg.BrushTool.BrushFill := iebfTextured;
  RightImg.BrushTool.BrushSize := 50;
  RightImg.BrushTool.BrushColor := clRed;
  RightImg.MouseInteract := [miBrushTool];
  RightImg.BrushTool.PaintMode := iepmContinuous;

The code works fine, and I can see an animated brush drawing random lines.
However, I'd like to avoid the mouse events. When the application runs I don't like the idea of 'hijacking' the mouse for this effect. My preferred solution would be to use code to move the brush in the background, with no mouse interactions required, and then show it after a final refresh.

Can this be done?

Thanks for your support,
Sybren
5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Oct 07 2018 : 17:40:46
Excellent

Nigel
Xequte Software
www.imageen.com
Sybren Posted - Oct 07 2018 : 14:52:12
Hi Nigel,

With your 8.1.1 release the brush now perfectly works in code.
Thank you for the quick action!

Sybren
xequte Posted - Sep 20 2018 : 01:30:07
Sorry Sybren,

I just remembered, those are not public properties in 8.1.0. I will make them so in 8.1.1 (next week).


Nigel
Xequte Software
www.imageen.com
Sybren Posted - Sep 19 2018 : 05:43:42
Hi Nigel,

Thank you for your prompt response.

I tried to apply the example code, but it seems that these (e.g. '.StartPainting') are actions of the TImageEnView component?

Sorry to say... I'm not familiar with actions. Perhaps a simple hint or example how to use the code is very welcome.

Thanks for your support.

Sybren
xequte Posted - Sep 18 2018 : 16:59:21
Hi Sybren

I'm sorry, there are actually some useful methods for this, but they are not easily discoverable in the documentation (I will improve that).

Please see:

https://www.imageen.com/help/TIEBrushToolInteraction.StartPainting.html

Which will allow you to achieve this without faking mouse movements.




Nigel
Xequte Software
www.imageen.com