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
 Drawing a polygon
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yeohray2

Malaysia
98 Posts

Posted - Jan 18 2023 :  02:06:13  Show Profile  Reply
I need to draw a polygon, using the mlDrawCreatePolylineLayers setting. However, I find that I can draw smoother shapes using the miSelectPolygon setting (then create a polyline layer from the selection). It's more obvious when using a pen on a touch screen to draw the area - especially the 2nd point in the polyline layer - there seems to be an area around the first point where it will not register any changes. Using the miSelectPolygon, it's easier to draw an arbitrary shape.

Are there any settings to have the mlDrawCreatePolylineLayers setting be as responsive as the miSelectPolygon setting?

Also, there is a pause when I set the MouseInteractLayers := [mlDrawCreatePolylineLayers], before I can start drawing. Is this normal?

Thanks in advance.
Ray

xequte

37479 Posts

Posted - Jan 18 2023 :  20:47:11  Show Profile  Reply
Hi Ray

I tried using both mlDrawCreatePolylineLayers and miSelectPolygon to draw around a circle and could not find any significant difference:



The main factor affecting smoothing is the spacing of the points, which is determined by the frequency of MouseMove calls. ImageEn is not restricting this in any way.

Can you confirm whether any of the following make any difference:
- Setting ImageEnView.LayersFastDrawing := iefDelayed; // or iefFast
- Turning off AutoShrink and AutoStretch
- Setting ImageEnView1.LayersCaching := 0;

Regarding the pause before drawing, does this only happen the first time? Does turning off undo affect it?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yeohray2

Malaysia
98 Posts

Posted - Jan 19 2023 :  00:36:31  Show Profile  Reply
Hi Nigel,

Thanks for the suggestions, I'll play around with them and see how it goes.

Yes, the pause before drawing, it happens only the first time. How do you turn off undo? Is it to set the LayersCaching := 0;?

Ray
Go to Top of Page

xequte

37479 Posts

Posted - Jan 19 2023 :  14:46:51  Show Profile  Reply
Hi Ray

Sometimes the initialization of GDI+ can take a moment.

To disable undo:

ImageEnView1.Proc.AutoUndo := false;

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yeohray2

Malaysia
98 Posts

Posted - Jan 20 2023 :  03:13:28  Show Profile  Reply
On my machine (i5-8400), it takes about 2.5 seconds before the mouse is responsive after the call to viewMain.MouseInteractLayers := [mlDrawCreatePolylineLayers];, in both debug and release modes, in both 32 and 64-bits.

And yes, it's the call to InitGDIPFont that's causing the delay. I'll follow the suggestions here (https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=3727) to initialize it earlier.
Go to Top of Page

xequte

37479 Posts

Posted - Jan 20 2023 :  16:06:54  Show Profile  Reply
Hmmm, so if you set:

IEGlobalSettings().HintStyle.Transparency := 255;

It resolves the issue? I might make that the default for the next update.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yeohray2

Malaysia
98 Posts

Posted - Jan 20 2023 :  19:30:54  Show Profile  Reply
I didn't try that. I just called something like

viewInitGDI.IEBitmap.IECanvas.MeasureText(' ');

during a 'busy' period to initialize it and hide the delay :)
Go to Top of Page

xequte

37479 Posts

Posted - Jan 21 2023 :  15:37:34  Show Profile  Reply
Hi

Please try:

IEGlobalSettings().HintStyle.Transparency := 255;

And let me know if it prevents the delay completely.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yeohray2

Malaysia
98 Posts

Posted - Jan 22 2023 :  10:46:54  Show Profile  Reply
Hi,

Settings the HintStyle.Transparency property doesn't make a difference on my system - the delay is still the same for the first call to MouseInteractLayers := [mlDrawCreatePolylineLayers];

Ray
Go to Top of Page

xequte

37479 Posts

Posted - Jan 23 2023 :  18:24:10  Show Profile  Reply
Sorry Ray, I'm not sure what is happening here. When setting MouseInteractLayers := [mlDrawCreatePolylineLayers], InitGDIPFont should be called automatically if EnableInteractionHints is enabled.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yeohray2

Malaysia
98 Posts

Posted - Jan 27 2023 :  04:24:08  Show Profile  Reply
Hi NIgel,

I don't think anything is wrong at this point. There is just an unavoidable delay due to having to initialize the GDI+ stuff. Or were you expecting a different result?

Basically I load the image and set up the settings you suggested:

procedure TForm30.FormShow(Sender: TObject);
begin
  viewPen.IO.LoadFromFile('f:\temp\test.bmp');
  viewPen.Proc.AutoUndo := False;
  viewPen.EnableInteractionHints := True;
  IEGlobalSettings.HintStyle.Transparency := 255;
  viewPen.Update;
end;


I then have another button where I set the polyline drawing mode:

procedure TForm30.Button2Click(Sender: TObject);
begin
  viewPen.LayersAutoClosePolylines := iecmAlways;
  viewPen.MouseInteractLayers := [mlDrawCreatePolylineLayers];
end;


It is during this event that there is a delay. Which is fine because I now know to initialize the GDI+ stuff in an earlier part of my application to avoid this delay.

Ray
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: