libspng icon indicating copy to clipboard operation
libspng copied to clipboard

Premultiply alpha option

Open capr opened this issue 3 years ago • 1 comments

Most graphics libs (all?) can only blend premultiplied-alpha sources. Maybe out-of-scope for libspng, but since libpng has the feature, it may be worth to add it.

EDIT: Note that most PNGs in the wild are already in premultiplied alpha but there's no bit in the file to tell if that's the case. So most (all?) of the time a premultiply pass would just be a waste of energy to satisfy the spec. AFAIR the loading time in libpng doubles because of this (tested that years ago, that might have changed).

capr avatar Dec 26 '21 11:12 capr

Here's the code for it in case anyone needs it: https://github.com/luapower/libspng/blob/master/csrc/libspng/premultiply.c

capr avatar Dec 30 '21 19:12 capr