afrantzis / pixel-format-guide

Pixel Format Guide
https://afrantzis.github.io/pixel-format-guide
GNU Lesser General Public License v2.1
68 stars 10 forks source link

Distinguish premultiplied alpha vs non-premultiplied alpha #4

Open nigeltao opened 3 years ago

nigeltao commented 3 years ago

Feature request: have the pfg tool and/or the docs state whether various formats-with-alpha use premultiplied (associated) or non-premultiplied (unassociated) alpha.

For example, https://www.cairographics.org/manual/cairo-Image-Surfaces.html#cairo-format-t states that CAIRO_FORMAT_ARGB32 uses premultiplied alpha. Quoting from that link: "50% transparent red is 0x80800000, not 0x80ff0000".

Is CAIRO_FORMAT_ARGB32 equivalent to SDL_PIXELFORMAT_ARGB8888 (in terms of alpha semantics, not just byte order) or would I have to do a "premul to non-premul" conversion? I think that's the sort of question that's within the Pixel Format Guide's scope.

nigeltao commented 3 years ago

Confusingly, while CAIRO_FORMAT_ARGB32 uses premultiplied alpha, cairo_set_source_rgba uses non-premultiplied alpha, AFAICT.

nigeltao commented 3 years ago

pixman uses premultiplied alpha: https://stackoverflow.com/questions/24172540/pixman-compositing-vs-alpha-blending https://lists.freedesktop.org/archives/pixman/2014-June/003265.html