image-gif icon indicating copy to clipboard operation
image-gif copied to clipboard

Explore dithered alpha frame constructor

Open 197g opened this issue 5 months ago • 1 comments

When we create a palette for an image from RGBA8 and LA8 we use alpha > 0 as a hard-coded condition for transparency. There's of course alternatives for this such as alpha > 127 etc. In the end, these functions aim at good approximation with practical compute costs. We could offer alternative constructors. In particular, dithering is an solution space for matching colors with a limited palette, maybe we could use a similar algorithm to dither transparency such that the total transparency over an area roughly matches the underlying transparency.

Solutions should be well-defined enough to be maintainable, i.e. have clear usage guidelines and documented characteristics.

Raised here: https://github.com/image-rs/image-gif/pull/223#discussion_r2551364747

197g avatar Nov 23 '25 13:11 197g

alpha > 127 is what I need for wondermagick: https://github.com/Shnatsel/wondermagick/issues/59

I could also work around that in alpha adjustment prepass at the cost of some performance.

Shnatsel avatar Dec 14 '25 14:12 Shnatsel