Lazarus

Programming => Graphics => Graphics and Multimedia => BGRABitmap and LazPaint => Topic started by: DidaJI on June 08, 2021, 10:45:30 am

Title: TBGRABitmap picture color correction
Post by: DidaJI on June 08, 2021, 10:45:30 am
Hi, I need help correcting the color of the whole picture. For example, I need to reduce the color red, etc.
I suppose it could be done with BGRAReplace(picture, picture.Filter......), but somehow I can't.
I can do, for example, a blur filter, rotation, resizing, but I can't change the color shade.

Can anyone give me an example of how to do this?

Thanks a lot, Zdenek.
Title: Re: TBGRABitmap picture color correction
Post by: winni on June 08, 2021, 10:57:58 am
Hi!

This example shows you how to reduce the red part with 128:
Code: Pascal  [Select][+][-]
  1. var img: TBGRABitmap;
  2. i : Integer;
  3. p: PBGRAPixel;
  4.  
  5. begin
  6. ....
  7.  p := img.data;
  8.     for i := 0 to  img.NbPixels -1  do
  9.         begin
  10.         if p^.red > 128 then p^.red := p^.red - 128 else p^.red := 0;
  11.        inc(p);
  12.         end;  
  13.  img.InvalidateBitmap;
  14. end;                    
  15.  
  16.  

Winni
Title: Re: TBGRABitmap picture color correction
Post by: DidaJI on June 08, 2021, 12:39:05 pm

It works, thanks very!

Zdenek.
TinyPortal © 2005-2018