Recent

Author Topic: Example image manipulations with little bug  (Read 1092 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Example image manipulations with little bug
« on: November 06, 2019, 12:10:49 pm »
Hi guys, for a recent job I had to develop a library to implement the most common image manipulations. That's why I created a public project on GitHub at

https://github.com/XinYiMan/simple_image_manipulation

I tested on Mac OS X and apart from a mismatch on the manipulation of the gamma value seems to work well.
So if someone were to serve, he didn't reinvent the wheel all the time.

The problem is in the manipulation of the gamma value. If I take an image and do the gamma encoding it works fine. If I then apply the decode gamma immediately it seems to not work. But if I result from the encode gamma save it on a file which I then re-import and apply the decode range then it works. I don't understand why. Who explains to me what is wrong?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Example image manipulations with little bug
« Reply #1 on: November 06, 2019, 12:16:58 pm »
My image gamma manipulation test
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: Example image manipulations with little bug
« Reply #2 on: November 06, 2019, 02:36:38 pm »
Hi,

After writing directly to pixel data, you need to call InvalidateBitmap. On MacOS, it won't work otherwise because the pixel data is not linked to the bitmap handle.

Note that using Canvas property is not recommended as it requires copying from the bitmap handle and vice versa. Also the alpha channel is not well supported by Canvas.

For example, to copy a part, you can directly use the GetPart function. Otherwise if you want functions that are Canvas-like, you can safely use CanvasBGRA property instead.

Regards
Conscience is the debugger of the mind

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Example image manipulations with little bug
« Reply #3 on: November 06, 2019, 02:50:12 pm »
Hi,

After writing directly to pixel data, you need to call InvalidateBitmap. On MacOS, it won't work otherwise because the pixel data is not linked to the bitmap handle.

Note that using Canvas property is not recommended as it requires copying from the bitmap handle and vice versa. Also the alpha channel is not well supported by Canvas.

For example, to copy a part, you can directly use the GetPart function. Otherwise if you want functions that are Canvas-like, you can safely use CanvasBGRA property instead.

Regards
Thank you. With InvalidateBitmap after pixel editing run correctly on Mac OS X.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018