Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate the idea of premultiplied alpha in PixelType #52

Open
1 of 2 tasks
p0nce opened this issue Jun 28, 2023 · 5 comments
Open
1 of 2 tasks

Investigate the idea of premultiplied alpha in PixelType #52

p0nce opened this issue Jun 28, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@p0nce
Copy link
Collaborator

p0nce commented Jun 28, 2023

  • A. If we add 6 new pixel types (lap, rgbap for 8-bit, 16-bit and 32-bit FP), then we can support pre-multiplied with quite a bit of changes. The interesting thing is that PNG with the unspecified ipHone PNG does support premultiplied

or

  • B. Decode unpremultiplied always, do not keep track of status, just provide ways to do it and undo it at the discretion of the user. This is simpler, but people will not get the advantages of premultiplied or less often.

  • Does premultiplied alpha encodes better, and how much better in terms of space? Check with PNG and QOIX. => YES, 2x better for some QOIX overlays!

  • Implement function to premultiply, or unpremultiply. This is the easy part, already exist in Dplug ImageKnob.

Big question is (above) whether to keep that information in the type system (PixelType) or not. This is NOT a LayoutOptions, and I don't think it should be a separate status also. Premultiplied alpha is better for compositing, but not for editing. It also looses a bit of data, but it repeatable.

@p0nce p0nce added the enhancement New feature or request label Jun 28, 2023
@p0nce
Copy link
Collaborator Author

p0nce commented Jun 28, 2023

In future world, PixelType will probably explode in complexity with opEquals being non-trivial. What would be those additions?
I can think of color spaces, specific encoding, chroma sitting, etc. Some types will also not make sense, like:

 (RGB, ubyte, premultiplied, null colorspace)    // no good to have 'premultiplied alpha' without alpha
  • Must choose whether to YAGNI this or not. Pixel Type would become non-POD, because of ICC. Bleh.
    • Can something with an ICC be POD? A reference type for this would be a bit meh.

@p0nce
Copy link
Collaborator Author

p0nce commented Jun 30, 2023

The reading of the color library made by Manu is interesting and points towards the likely shape of a future "Colorspace" concept, which would either the same as PixelType or PixelType would be purely derived from it.

Now, is there a way to support the less types "legacy" PixelType?

@p0nce
Copy link
Collaborator Author

p0nce commented Jul 7, 2023

Very much related to #20

@p0nce
Copy link
Collaborator Author

p0nce commented Jul 21, 2023

Important to note that some practical overlay images are largely transparent and can benefit a lot from premultiplied encoding, but not really from "ignore color for fully transparent areas" which is a less strong thing somehow. That would make the QOIX codec not lossless in 8-bit contrarily to today.

@p0nce
Copy link
Collaborator Author

p0nce commented Aug 4, 2023

Premultiplied alpha doesn't seem to strictly need ICC profile or full colorspace struct. We can still chug along, ignoring colorspace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant