Search code examples
c++image-processinglibpng

What is the value for white in this png filter?


I have this short code in C++ : png_set_filler(png, 0xFF, PNG_FILLER_AFTER);
This colored the transparent pixels in black.
I think that 0xFF means black. What is the value for white ?
Thanks


Solution

  • That function takes packed (alpha-less RGB) values and adds an alpha channel.

    png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
    

    The filler is the value to put in the unpacked alpha channel. The final param is either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, which places the filled channel before or after the RGB values -- ARGB or RGBA, respectively.

    The docs say, "To add an opaque alpha channel, use filler=0xff [or 0xffff for 16-bit color channels]", which I believe means no transparency so it will show up as whatever the RGB values are (in your case, that is presumably all zeros). Note that, as I read the docs, using this function on an already unpacked PNG has no effect -- i.e., it doesn't to modify the fill value.

    If your RGB values were, say, 0xff0000, that would be solid red. If unpacked red pixels and set the fill channel to 0x7f, that should make it half-transparent red.