Related to #1543, it's very easy to introduce transparency-related bugs with ColorBgra from mixing up straight alpha vs premultiplied alpha.
Since this is our pixel type for directly manipulating a Cairo.ImageSurface's data (which is always premultiplied alpha), I think ColorBgra also should only ever store premultiplied alpha
Related to #1543, it's very easy to introduce transparency-related bugs with
ColorBgrafrom mixing up straight alpha vs premultiplied alpha.Since this is our pixel type for directly manipulating a
Cairo.ImageSurface's data (which is always premultiplied alpha), I thinkColorBgraalso should only ever store premultiplied alphaColorBgra.FromUInt32(), e.g.RandomColorBgra()ColorBgra.Blend(), which expects straight alpha (see Add a replacement for ColorBgra.Blend() which didn't use premultiplied alpha #1546 )ColorBgra.NewAlpha()with a version that expects the color to be in premultiplied alpha (done in Port ColorBgra.NewAlpha() to work with premultiplied alpha #1645)ToPremultipliedAlpha()andToStraightAlpha()should be made private if possible. The conversion functions to and fromCairo.Color(which is in straight alpha) should do the alpha conversion as well since it's very easy to accidentally miss this.ColorDifference()which seems to multiply by alpha (done in Fix the color difference comparison's handling of alpha #1639)HexString-related methods could likely be merged intoCairo.Color(done in Consolidate methods for converting colors to/from hex strings #1626)