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
 Is it normal to use the TextOut method of TImageEnProc to take about 240ms
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Flashcqxg

93 Posts

Posted - Sep 26 2021 :  20:51:28  Show Profile  Reply
Is it normal to use the TextOut method of TImageEnProc to take about 240 milliseconds?

SW := TStopwatch.StartNew;
Proce.TextOut(50, 50, 'SS', 'Times New Roman', MarkTextFontSize, clRed, [fsBold]);
Memo1.Lines.Add(SW.ElapsedMilliseconds.ToString);

xequte

38180 Posts

Posted - Sep 26 2021 :  21:05:14  Show Profile  Reply
Hi

TImageEnProc.TextOut actually uses GDI+ under the hood (for transparency and other features). The first time GDI+ is used it needs to be initialized which is slow, but subsequent calls should be much faster, for instance, when i tested your code five times, I got

200ms
1ms
1ms
<1ms
1ms


If you want to avoid this, use TCanvas.TextOut instead.

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

Flashcqxg

93 Posts

Posted - Sep 26 2021 :  21:23:08  Show Profile  Reply
Hi,my test:
procedure TForm1.Button1Click(Sender: TObject);
var
  IO: TImageEnIO;
  Proce: TImageEnProc;
  I: Integer;
  SW: TStopwatch;
begin
  IO := TImageEnIO.Create(nil);
  IO.Params.PDF_PaperWidth := 1190;
  IO.Params.PDF_PaperHeight := 842;
  Proce := TImageEnProc.CreateFromBitmap(IO.IEBitmap);
  IO.LoadFromFileJpeg(ExtractFilePath(ParamStr(0)) + '1.JPEG');
  try
    for I := 1 to 10 do
    begin
      SW := TStopwatch.StartNew;
      Proce.TextOut(50, 10 * I, 'SSS', 'Times New Roman', 35, clRed, [fsBold]);
      Memo1.Lines.Add(SW.ElapsedMilliseconds.ToString);
    end;
  finally
    IO.Free;
    Proce.Free;
  end;
end;


result:
294
267
267
268
268
265
267
268
270
267
Go to Top of Page

xequte

38180 Posts

Posted - Sep 27 2021 :  20:18:39  Show Profile  Reply
Hmmm, i cannot reproduce that.

249
20
20
20
21
21
21
21
21
21



What version of Delphi and Windows are you using? Is there any other code or ImageEn components in that test project?


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

Flashcqxg

93 Posts

Posted - Sep 27 2021 :  22:53:32  Show Profile  Reply
No any other code or ImageEn components in this test project.
Delphi 10.3.2 and Windows 7
Go to Top of Page

Flashcqxg

93 Posts

Posted - Sep 27 2021 :  23:20:03  Show Profile  Reply
I found that the larger the picture, the slower the speed; the smaller the picture, the faster the speed. The image size I tested before was 3307*2339(316kb). Just now I tested a 4960*3508(588kb) image. The test results are as follows:

665
623
624
621
619
623
621
620
622
621
Go to Top of Page

xequte

38180 Posts

Posted - Sep 28 2021 :  23:19:19  Show Profile  Reply
Sorry, is this ImageEn 10.2.0?

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

Flashcqxg

93 Posts

Posted - Sep 28 2021 :  23:22:08  Show Profile  Reply
Yes,i test with delphi 10.3.3+windows7 + ImageEn 10.2
Go to Top of Page

xequte

38180 Posts

Posted - Sep 28 2021 :  23:41:02  Show Profile  Reply
Hi

Please try the EXE files in the following zip and let me know what timings you get:

www.imageen.com/temp/TextOutTest.zip


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

Flashcqxg

93 Posts

Posted - Sep 28 2021 :  23:46:16  Show Profile  Reply
Project1_32

TEST 1...
298
279
283
278
280
280
281
279
278
281
TEST 2...
314
297
299
295
297
299
295
294
295
296



Project1_64:
TEST 1...
386
364
366
361
363
372
368
362
370
365
TEST 2...
393
380
384
383
383
396
384
381
385
384
Go to Top of Page

xequte

38180 Posts

Posted - Sep 29 2021 :  00:00:20  Show Profile  Reply
Hmm, it must be an issue in Windows 7. If you need to support Windows 7, you should use TCanvas.TextOut instead.

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

Flashcqxg

93 Posts

Posted - Sep 29 2021 :  19:47:59  Show Profile  Reply
I don't think so, my test results on windows10 are as follows. You can use my test picture for testing, I uploaded it.

Memo1
TEST 1...
417
452
407
408
411
405
397
396
442
409
TEST 2...
414
401
466
378
346
349
339
332
359
374



Go to Top of Page

xequte

38180 Posts

Posted - Sep 29 2021 :  21:25:42  Show Profile  Reply
Hi

Your image works here, though is a little slow. I will investigate the code some more.

TEST 1...
1780
200
196
196
196
199
197
195
199
197
TEST 2...
229
215
216
216
217
213
216
216
230
213


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

Flashcqxg

93 Posts

Posted - Sep 29 2021 :  21:27:42  Show Profile  Reply
Thank you, hope there is a good solution.
Go to Top of Page

xequte

38180 Posts

Posted - Sep 29 2021 :  22:46:33  Show Profile  Reply
Hi

We've added extra checking and if the image has no alpha channel (like your image) then we can make it around 8x faster. Please email me for the update.

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

Flashcqxg

93 Posts

Posted - Sep 29 2021 :  22:53:09  Show Profile  Reply
This is good news. I will wait for the next version to be released before upgrading, thank you.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: