David Hodson wrote:
> "Steinar H. Gunderson" wrote:
> > GIMP already does this (32-bit = RGBA, the `extra' 8 bits is an alpha channel,
> > used for transparency information), and has done for a long time now.
Calvin Williamson recommended "Image Composition
Fundamentals" by Alvy Ray Smith, for a review
and advantages of the technique.
> At the moment, as far as I can tell, the Gimp cannot handle
> pre-multiplied rgba images.
Yes. In fact, in generating the projection images (app/paint_func.c) Gimp
pretty much does the "unmultiplied case" in the above
cite, including the "second composition" step to recover an unmultiplied
layer from a premultiplied intermediary result. From the premultiplied
viewpoint, that's a lot of unnecesary multiply and divides.
> Example: render an rgba image. (I was using
> some PovRay output; I presume it does a reasonable job.) Now create a
> flat colour background in the Gimp, lay the rgba image on top, and try
> to get a clean composite without black fringing. I don't think it can
> be done,
It can't be done, in my opinion. What we surmise to be [R*A, G*A, B*A, A]
Gimp assumes to be [R, G, B, A] and reads the color components as
near black for near transparent regions. That makes black fringing unavoidable.
> though I'd love to be proven wrong. (There could be issues
> here with different gamma handling between PovRay and the Gimp, but I
> suspect the problem is simply a failure to handle rgba properly.)
If all we had to care about was an efficient pipeline, premultiplied is the
way to go - but there's more to Gimp than its rendering pipeline. There
are tools that are relatively simple to code with unmultiplied layers, but are
difficult or impossible to do with premultiplied ones. How would the unerase
tool deal with full transparent premultiplied alpha [A*R = A*G= A*B = A = 0]?
Look for some back door on an undo stack? Premultiplication buys its efficiency
by removing information content from the layer.
The performance arguments advanced by Smith are compelling, and his pipeline
is computationally cleaner, but the last time I did any serious
performance measurement on the pipeline was a low-teens Gimp, and compositing
to the projection was not a big comsumer compared to building buffered writes
to the X server (this was, I recall, not built with threads enabled).
My two U. S. cents