Recent

Author Topic: [SOLVED] Replacing a color  (Read 1192 times)

AsleyCruz

  • Full Member
  • ***
  • Posts: 108
    • Graphic and web designer
[SOLVED] Replacing a color
« on: August 17, 2023, 07:24:42 am »
Hi coders

I have more than 20 png transparent images (like attached image) and would like to replace/fill
all black color (pixels) to white or another custom color using TBGRABitmap, but I want to keep the transparency.

How can I do this? Hope it can be possible. Thanks.
« Last Edit: August 17, 2023, 08:22:26 am by AsleyCruz »
Graphic & web designer

cdbc

  • Hero Member
  • *****
  • Posts: 1656
    • http://www.cdbc.dk
Re: Replacing a color
« Reply #1 on: August 17, 2023, 07:53:46 am »
Hi
I just use "LazPaint" to do this sort of thing. "LazPaint" is the showpiece of BGRABitmap library, which is available in OPM, great library, can do a bunch of neat stuff...
I guess it's a matter of running over your individual pixels and manipulate color and/or transparency, might even be possible with laz' inhouse TBitmap?!?
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Handoko

  • Hero Member
  • *****
  • Posts: 5376
  • My goal: build my own game engine using Lazarus
Re: Replacing a color
« Reply #2 on: August 17, 2023, 07:58:50 am »
If you're using TCanvas, in the link below:
https://wiki.freepascal.org/Portal:HowTo_Demos

Goto the Graphics category and find these:
- Get pixel color, there you can learn how to detect transparent pixels
- Change background color, there you can learn how to change color of the pixels
 

paweld

  • Hero Member
  • *****
  • Posts: 1268
Re: Replacing a color
« Reply #3 on: August 17, 2023, 08:12:41 am »
BGRABitmap and ReplaceColor
Best regards / Pozdrawiam
paweld

AsleyCruz

  • Full Member
  • ***
  • Posts: 108
    • Graphic and web designer
Re: Replacing a color
« Reply #4 on: August 17, 2023, 08:22:43 am »
BGRABitmap and ReplaceColor

Thanks a lot, paweld, worked like a charm.

Thanks @Handoko and @cdbc too
Graphic & web designer

 

TinyPortal © 2005-2018