You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
In decoders with Identify implementations (PNG, BMP)
For all built-in pixel formats (IPixel-s)
API alternatives
In #1394 (reply in thread) I forgot that extending IPixel is actually a breaking change. Non-breaking variant:
internalenumPixelAlphaRepresentation{None,Associated,Unassociated}publicclassPixelTypeInfo{// 'null' means unknown/not implementedpublicPixelAlphaRepresentation?AlphaRepresentation{get;}}publicPixelOperations<TPixel>{// Return AlphaRepresentation == null by default, but for important pixel types, introduce proper overrides with T4:publicvirtualPixelTypeInfoGetPixelTypeInfo();}
@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 detect PixelTypeInfo details.
I 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.
Activity
JimBobSquarePants commentedon Oct 24, 2020
I can see us adding
ChannelCountto this type at some point so I guess that would be nullable also.antonfirsov commentedon Oct 24, 2020
@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 detect
PixelTypeInfodetails.JimBobSquarePants commentedon Oct 24, 2020
Yeah, it's a safe clever approach. Big fan!
saucecontrol commentedon Oct 27, 2020
I 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.
JimBobSquarePants commentedon Oct 28, 2020
Oh I remember this stuff yeah, will definitely have to use it as a source of inspiration!
antonfirsov commentedon Nov 2, 2020
@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.saucecontrol commentedon Nov 2, 2020
Yep, that's right. DirectX uses
Ignore,Premultiplied, andStraightto describe those values. I'm not sure which is more intuitive.JimBobSquarePants commentedon Nov 2, 2020
I much prefer your naming.
JimBobSquarePants commentedon Nov 7, 2020
I've started this.