Recent

Author Topic: [SOLVED] graphics speed  (Read 1603 times)

johnathan

  • New member
  • *
  • Posts: 6
[SOLVED] graphics speed
« on: August 25, 2021, 05:20:56 pm »
Hi
I have recently written a program to clear up my scanned documents by checking each pixel and make changes where necessary  It runs and does exactly what I require, but is very slow, it took two  minutes and 33 seconds to process a 795 x 948 document.

This is  long so I checked program by writing it in old Delphi 4.
This gave a process time of 16 seconds.

 I am obviously doing something wrong in Lazarus, can anyone help please, or point me to some simple  way of speeding up the program.

It does need to be simple because of my ability.

Regards stay safe

John
« Last Edit: August 31, 2021, 12:56:22 pm by johnathan »

winni

  • Hero Member
  • *****
  • Posts: 2802
Re: graphics speed
« Reply #1 on: August 25, 2021, 05:39:55 pm »
Hi!

Please show us some code how you access your document.

Otherwise we only could make some hazard  guss.

Winni

wp

  • Hero Member
  • *****
  • Posts: 9021
Re: graphics speed
« Reply #2 on: August 25, 2021, 07:20:31 pm »
You probably access the image pixels via the Pixels[x,y] property of the canvas. This is very very slow. Your delphi program probably had used the ScanLine method to access the pixels which is much faster. You can use the same code in Lazarus now, too. Alternatively you can find in https://wiki.lazarus.freepascal.org/Fast_direct_pixel_access some alternative methods for fast pixel access (a bit outdated, though).
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

johnathan

  • New member
  • *
  • Posts: 6
Re: graphics speed
« Reply #3 on: August 31, 2021, 12:55:51 pm »
Hi

Thanks for your reply.
Yes I am using pixels[x,y] properties to read and right to the canvas, whereas with Delphi I think I access the bitmap.
I will now look at your link suggestion and see how I get on.
After this I will mark the my post as Solved as I now know what the problem is.
Thanks and stay safe
John

Looking at the link you gave me, I think it  may be a challenge  as I am not a programmer, its more of a hobby.  But I will give it a try as time is not an issue, and will keep the mind active in these unusual times.

Thanks again

John
« Last Edit: September 02, 2021, 10:43:26 am by johnathan »

 

TinyPortal © 2005-2018