Lazarus

Programming => Operating Systems => Linux => Topic started by: johnathan on August 25, 2021, 05:20:56 pm

Title: [SOLVED] graphics speed
Post by: johnathan 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
Title: Re: graphics speed
Post by: winni 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
Title: Re: graphics speed
Post by: wp 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).
Title: Re: graphics speed
Post by: johnathan 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
TinyPortal © 2005-2018