Re: Simple API and associated alpha
Samuel Williams <[email protected]>
| Newsgroups | gmane.comp.graphics.png.devel |
|---|---|
| Message-ID | <CAHkN8V9LFQ=ZOYZpnU=bnzc7gE=18qJaJNOOuZa5-OyS4+RZ1w@mail.gmail.com> |
I've taken another look at the code, it seems like the simplest way to fix this would be to add PNG_FORMAT_FLAG_ASSOCIATED_ALPHA - would a PR be accepted? On 6 September 2017 at 14:13, Samuel Williams < [email protected]> wrote: > Okay I took another look at the documentation and I think I see what's > going on. > > > The channels are encoded in one of two ways: > a) As a small integer, value 0..255, contained in a single byte. For the > alpha channel the original value is simply value/255. For the color or > luminance channels the value is encoded according to the sRGB specification > and matches the 8-bit format expected by typical display devices. > The color/gray channels are not scaled (pre-multiplied) by the alpha > channel and are suitable for passing to color management software. > b) As a value in the range 0..65535, contained in a 2-byte integer, in > the native byte order of the platform on which the application is running. > All channels can be converted to the original value by dividing by 65535; > all > channels are linear. Color channels use the RGB encoding (RGB end-points) > of > the sRGB specification. This encoding is identified by the > PNG_FORMAT_FLAG_LINEAR flag below. > When the simplified API needs to convert between sRGB and linear > colorspaces, > the actual sRGB transfer curve defined in the sRGB specification (see the > article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 > approximation used elsewhere in libpng. > When an alpha channel is present it is expected to denote pixel coverage > of the color or luminance channels and is returned as an associated alpha > channel: the color/gray channels are scaled (pre-multiplied) by the alpha > value. > The samples are either contained directly in the image data, between 1 and > 8 > bytes per pixel according to the encoding, or are held in a color-map > indexed > by bytes in the image data. In the case of a color-map the color-map > entries > are individual samples, encoded as above, and the image data has one byte > per > pixel to select the relevant sample from the color-map. > > > So, it wasn't clear to me the paragraphs following a) and b) were related. > So, for part a), this means for single byte pixel formats, "The color/gray > channels are not scaled (pre-multiplied) by the alpha > channel and are suitable for passing to color management software." I > wrongfully inferred the organisation of that documentation due to the lack > of indentation/titles. > > So, I'm going to assume that when loading 8-bit formats, I can't use the > simple API if I want pre-multiplied data. Is that correct? > > Thanks > Samuel > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ png-mng-implement mailing list png-mng-implement-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/png-mng-implement