Recent

Author Topic: How to speedup GR32/Graphic32 when handling large images?  (Read 609 times)

yogiyang

  • New member
  • *
  • Posts: 7
How to speedup GR32/Graphic32 when handling large images?
« on: July 05, 2020, 03:13:59 pm »
Hello,

I am using Graphic32 or GR32 in a project. It has most of the features that I need but when it comes to loading and handling large actual size images/photos that are snapped by modern Digital SLR cameras or mobiles it is very slow.

Is there any way by which we can speedup GR32?

Or is there any alternate library that has most of the features of GR32?

TIA

Yogi Yang

wp

  • Hero Member
  • *****
  • Posts: 7624
Re: How to speedup GR32/Graphic32 when handling large images?
« Reply #1 on: July 05, 2020, 05:29:28 pm »
It depends on what you want to do with the images. Maybe FreeImage (https://freeimage.sourceforge.io/download.html) or Vampyre Imaging (https://github.com/galfar/imaginglib, or Online-Package-Manager) are faster in loading. They have less image processing capabilities, though.

In an old project I could achieve very fast jpg reading by using the Intel Jpeg Library (IJL). Unfortunately it has been abondoned, but you'll certainly find it somewhere it the net. It worked with Delphi, but I don't see a reason why it should not be convertable to Lazarus. Of course, Windows only...

Or try BGRABitmap.

-------------

I just found the old Delphi project and built a little Lazarus demo. I tested a 16MB image and it load within 0.45 s with the IJL library and within 2.2 s with the standard LCL jpeg routine. Note: demo requires Graphics32 to be installed into the IDE. The IJL dll is included in the download.
« Last Edit: July 05, 2020, 08:26:46 pm by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

yogiyang

  • New member
  • *
  • Posts: 7
Re: How to speedup GR32/Graphic32 when handling large images?
« Reply #2 on: July 06, 2020, 07:04:29 am »
Hello wp,

Thanks for your reply. Actually loading is not the only problem. Processing large images after loading them is the main problem. When we process the image using very simple process like adjusting its brightness and contrast is taking a hell of a time.

I also tested GraphicsMagicPro which has many algorithms which are useful for my need but this is written in Delphi. But the point here is that this is also very slow when it comes to processing medium to large images

TIA


wp

  • Hero Member
  • *****
  • Posts: 7624
Re: How to speedup GR32/Graphic32 when handling large images?
« Reply #3 on: July 06, 2020, 09:35:34 am »
AFAIK, GraphicsMagicPro is based on Graphics32, too. But I always thought that Graphics32 is one of the fast libraries. I never did a comparison with BGRABitmap - maybe you should try.

Or maybe only your images are too large? Nowadays everybody thinks that a good image needs to have a high mega-pixel count, and complains about longer and longer processing times.

What is the size of your images? How quickly can you process them with commercial software?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

circular

  • Hero Member
  • *****
  • Posts: 3508
    • Personal webpage
Re: How to speedup GR32/Graphic32 when handling large images?
« Reply #4 on: July 06, 2020, 10:09:55 am »
What is the resolution and format of those images?
Conscience is the debugger of the mind

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8785
  • FPC developer.
Re: How to speedup GR32/Graphic32 when handling large images?
« Reply #5 on: July 06, 2020, 10:46:48 am »
graphics32 seems to mostly have routines that operate on one pixel, not as many as will fit in a SSE register. (let alone AVX)

That means a call per pixel, and then some operations etc etc.

For something faster, it can be worthwhile to wrap relevant parts of the C++ simd or translate them.

They are one step better, using templates and intrinsics to expand per pixel operations to whole image routines.


 

TinyPortal © 2005-2018