Repository navigation
Introduce PixelTypeInfo.HasAlpha #1396
Description
Activity
I can see us adding
ChannelCountto this type at some point so I guess that would be nullable also.Reacted by Anton Firszov@JimBobSquarePants so you prefer the non-breaking variant? Honestly, now it looks like a safer way to go to me.
Also allows us to extend codecs incrementally to detectPixelTypeInfodetails.Reacted by James Jackson-SouthYeah, it's a safe clever approach. Big fan!
Reacted by Anton FirszovI might be misreading the purpose of this, but did you consider support for pixel formats that are already premultiplied? TIFF and DirectX (among others) support alpha in both forms.
I recall we had a chat about this somewhere, although I've since lost track of it... I set up a generic pixel format descriptor type here which borrows heavily from WIC's pluggable pixel format model and describes alpha using an enum if you're looking for inspiration.
Reacted by James Jackson-South and Anton FirszovOh I remember this stuff yeah, will definitely have to use it as a source of inspiration!
@saucecontrol do I get this right?
None: has no alphaAssociated: has alpha, pixel is premultipliedUnassociated: has alpha, pixel is not premultiplied
@JimBobSquarePants edited my proposal, let's go with the non-breaking version + enum for
PixelAlphaRepresentation.Reacted by James Jackson-SouthYep, that's right. DirectX uses
Ignore,Premultiplied, andStraightto describe those values. I'm not sure which is more intuitive.Reacted by Anton FirszovI much prefer your naming.
Reacted by Anton FirszovI've started this.
Reacted by Anton Firszov
Motivation
By introducing a property to observe whether a given pixel type has an alpha, we can then use it in our processors to omit unnecessary alpha premultiplication. Might be also interesting for users working with
Image.Identify.We need to make sure it's value is properly filled:
Identifyimplementations (PNG, BMP)IPixel-s)API alternatives
In #1394 (reply in thread) I forgot that extending
IPixelis actually a breaking change. Non-breaking variant: