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
 how to create a smooth freehand draw
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

ted

Philippines
1 Posts

Posted - Feb 06 2017 :  10:12:53  Show Profile  Reply
Hi,

is it possible to create a smooth freehand draw in ImageEn?

Thanks in advance

Regards,
Ted

xequte

39052 Posts

Posted - Feb 06 2017 :  22:51:59  Show Profile  Reply
Sure, please see:

https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=2578
https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=31

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

w2m

USA
1990 Posts

Posted - Feb 09 2017 :  09:18:24  Show Profile  Reply
Also see this third party demo:
https://www.imageen.com/ieforum/attach/spetric/2016122217524_delphi_spe_demo.zip

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

w2m

USA
1990 Posts

Posted - Feb 10 2017 :  14:53:56  Show Profile  Reply
if you use this code the brush will be drawn as fast as possible without skipping:

Global Var
 ALastX: integer;
 ALastY: integer;
var
  iX: Integer;
  iY: Integer;
  iTransparency: Integer;
  iPenColor: TColor;
  iPenWidth: Integer;
begin
  iX := ImageEnView1.Layers[ImageEnView1.LayersCurrent].ConvXScr2Bmp(X);
  iY := ImageEnView1.Layers[ImageEnView1.LayersCurrent].ConvYScr2Bmp(Y);
  if (PaintBrush1.Down) and (ImageEnView1.MouseCapture) then
    begin
      { Paint Brush }
      with ImageEnView1 do
      begin
        iPenWidth := StrToIntDef(PenSize1.Text, 20);
        iPenColor := PenColor.Color;
        iTransparency := ieOpacityToAlpha(StrToIntDef(PenOpacity1.Text, 100));
        IEBitmap.Canvas.Pen.Width := iPenWidth;
        IEBitmap.Canvas.Pen.Color := iPenColor;
        IEBitmap.Canvas.MoveTo(iX, iY);
        IEBitmap.Canvas.LineTo(ALastX, ALastY);
        IEBitmap.AlphaChannel.Canvas.Brush.Color := iPenColor or (iTransparency)
          or (iTransparency shl 8) or (iTransparency shl 16);
        IEBitmap.AlphaChannel.CanvasCurrentAlpha := iTransparency;
        IEBitmap.AlphaChannel.Canvas.Pen.Width := iPenWidth;
        IEBitmap.AlphaChannel.Canvas.MoveTo(iX, iY);
        IEBitmap.AlphaChannel.Canvas.LineTo(ALastX, ALastY);
        Update;
      end;
    end;
end;

Place the above code in the OnMouseDown and OnMouseMove events.
Then add this to OnMouseMove:

  iX := ImageEnView1.Layers[ImageEnView1.LayersCurrent].ConvXScr2Bmp(X);
  iY := ImageEnView1.Layers[ImageEnView1.LayersCurrent].ConvYScr2Bmp(Y);
  ALastX := iX;
  ALastY := iY;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: