Recent

Author Topic: Quantize a PNG with TBgrabmp: How to do it?  (Read 2755 times)

Boleeman

  • Hero Member
  • *****
  • Posts: 781
Quantize a PNG with TBgrabmp: How to do it?
« on: December 31, 2024, 05:39:39 am »
Wondered if anyone has some sample code to quantize a png picture file with TBgrabmp ?


In my search I came across these (but was still looking for a TBgraBmp alternative):

PngDrop:     GUI tool for creating PNG8 (Done in Lazarus)

https://github.com/c-yan/pngdrop


I quickly played around with PNGDrop)
( written in Lazarus by a cluey Japanese guy c-yan  , Sunday programmer in Tokyo, Japan )

Here are my findings:
It contains some great ColorReduction pascal code that uses TLazIntfImage
Looks like it uses IntegerTripleArrays, KMeans, AverageError and Map Color with Dithering.
Uses drag and drop to load the png image and even saves it back to the original folder.
I tried it on a 233kB png and it compressed it to only 79kB. Amazing.
Also tried a 306kB transparent png and it compressed it to only 79kB.
(attached is the sample png that was compressed,)

« Last Edit: January 01, 2025, 02:06:33 am by Boleeman »

circular

  • Hero Member
  • *****
  • Posts: 4383
    • Personal webpage
Re: Quantize a PNG with TBgrabmp: How to do it?
« Reply #1 on: December 31, 2024, 04:59:11 pm »
Sure, here is an example to reduce to 256 colors:
https://forum.lazarus.freepascal.org/index.php?topic=61252.0
Conscience is the debugger of the mind

Boleeman

  • Hero Member
  • *****
  • Posts: 781
Re: Quantize a PNG with TBgrabmp: How to do it?
« Reply #2 on: January 01, 2025, 02:07:44 am »
Thank you circular and Happy New Year to you.

circular

  • Hero Member
  • *****
  • Posts: 4383
    • Personal webpage
Re: Quantize a PNG with TBgrabmp: How to do it?
« Reply #3 on: January 14, 2025, 05:54:45 pm »
You're welcome. Happy new year  :)
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018