Yes, though there are some subtleties.
PNG spec is clear that PNG files store alpha as unassociated. (Bad.)
OIIO is clear that the values delivered to the app should be associated alpha,
and so file format readers that encounter unassociated alpha are expected to
multiply the color channels by alpha in the process of copying the values to
the app's buffer.
Every once in a while, you want to bypass this conversion (usually to prevent
loss of precision), and the way you can do that for an ImageCache is:
imagecache->attribute ("unassociatedalpha", 1);
(You must do this BEFORE reading anything from the file.)
That will help you get the unassociated alpha when you want it. But Yang didn't
describe that -- he said he wanted premultiplied, and that should be what OIIO
is giving him. Maybe he described it backwards, and he wanted the original
unassociated? If so, see the above advice. The other possibility is that the
data is stored in the file already associated (in violation of the PNG spec),
and he's complaining about the fact that it's being double-corrected, and in
that case the answer also is to set the above attribute, and just know that the
value you're getting is the (unchanged) associated alpha.
The one thing we can't do is distinguish between unassociated alpha correctly
stored in the PNG, and associated alpha incorrectly stored in the PNG. Because
PNG stipulates that alpha is always unassociated (i.e. colors not
"premultiplied"), there is no PNG header field that indicates whether the alpha
is associated or not, because the spec says it always must be.
> On Apr 13, 2016, at 4:36 PM, Troy Sobotka <[email protected]> wrote:
>
> PNG, by specification, can only use unassociated alpha.
>
> With respect,
> TJS
>
>
> On Wed, Apr 13, 2016, 3:17 PM Yang Yang <[email protected]
> <mailto:[email protected]>> wrote:
> HI All,
>
> I am trying to read a bunch of png images supposed to have premultiplied
> alpha.
> However, it always give me unpremultiplied alpha.
>
> I don't know how can i configure Image cache to give me correct result.
>
> Could anyone give me suggestion?
>
> Thanks,
>
> Yang
> _______________________________________________
> Oiio-dev mailing list
> [email protected] <mailto:[email protected]>
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
[email protected]
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org