AngusJohnson / Image32

An extensive 2D graphics library written in Delphi Pascal
Boost Software License 1.0
137 stars 31 forks source link

Improve performance for GrayScale, InvertColors, AdjustHue, AdjustLuminance, AdjustSaturation #61

Closed ahausladen closed 4 months ago

ahausladen commented 4 months ago

Improve performance for GrayScale, InvertColors, AdjustHue, AdjustLuminance, AdjustSaturation

InvertColors Now uses XOR to invert all 3 color channels in one go.

AdjustHue, AdjustLuminance, AdjustSaturation These functions used to copy the fPixels array to a new HSL array and then back to a new fPixels array. Making them use 3 times the memory and suffering from dynamic array overhead (unnecessary zero-initialization via SetLength, CPU locks for reference management). The color conversion is now done directly in the fPixels array with a temporary helper variable.

AngusJohnson commented 4 months ago

Thanks again Andreas 👍.