[Bf-codereview] Alpha premul pipeline cleanup (issue 7018048)

brechtvanlommel at gmail.com brechtvanlommel at gmail.com
Sun Dec 30 11:32:10 CET 2012


On 2012/12/29 20:45:57, sergey.vfx wrote:
> > * For TIFF we should also read/write the metadata about the alpha
type?

> Eeeh.. Looked into this and ended up with complete misunderstanding of
TIFF
> logic. With current code if we'll save 8 bit TIFF and load it back,
we'll need
> to use Straight alpha mode, and for 16 bit TIFF rendered and opened in
blender
> we'll set alpha to Premul, which correlates with our assumptions.
However, 8 bit
> TIFF would be opened incorrect in Gimp, but will show correct in
Gwenview
> (default KDE image browser).

> Now, if at save time we'll use unassociated flag for 8 bit tiff, it'll
be
> displayed correct in Gimp. But we'll need to use Premul alpha mode
when opening
> it back in blender. And it will also look incorrect in Gwenview.

> So there's something crappy going on here and i can't figure this out
yet.

I think Gimp might not be reading the metadata then, since it seems we
are currently writing that the image as associated alpha (=
premultiplied alpha):
int extraSampleTypes[1] = { EXTRASAMPLE_ASSOCALPHA };

We should change that to EXTRASAMPLE_UNASSALPHA for byte images I think.

> However, byte buffers behaves quite fuzzy. When i do a stroke with
white brush
> on complete transparent image, i should see the whole stroke being
white in RGB
> display mode, but it fades up to darkish colors to the sides of brush.
> Converting pixels from straight-byte to premul-float in IMB_rectblend
and using
> IMB_blend_color_float doesn't give correct result here.

> Afraid that's the part of patch where i do need some help because i've
currently
> run out of ideas what's going on there.

This might actually just be a precision issue that we can't fix, thought
it depends what you are testing exactly.  2D painting in the image
editor currently always works as if using an Airbrush in Gimp. When
using a low strength this will give very clear rounding issues that you
will also find in Gimp using the same tool.

There might be another issue here as well though, I didn't test yet.

https://codereview.appspot.com/7018048/


More information about the Bf-codereview mailing list