mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Corrected simplified API default gamma for color-mapped output, added
a flag to change default. In 1.6.0 when the simplified API was used to produce color-mapped output from an input image with no gamma information the gamma assumed for the input could be different from that assumed for non-color-mapped output. In particular 16-bit depth input files were assumed to be sRGB encoded, whereas in the 'direct' case they were assumed to have linear data. This was an error. The fix makes the simplified API treat all input files the same way and adds a new flag to the png_image::flags member to allow the application/user to specify that 16-bit files contain sRGB data rather than the default linear. Fixed bugs in the pngpixel and makepng test programs.
This commit is contained in:
committed by
Glenn Randers-Pehrson
parent
f46106fa04
commit
2e92b4dfa0
@@ -440,7 +440,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
/* Palette with fixed color: the image rows are all 0 and the image width
|
||||
* is 16.
|
||||
*/
|
||||
memset(row, rowbytes, 0);
|
||||
memset(row, 0, rowbytes);
|
||||
}
|
||||
|
||||
else if (colors[0] == channels_of_type(color_type))
|
||||
@@ -624,8 +624,8 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
|
||||
gamma_table[0] = 0;
|
||||
|
||||
for (i=0; i<255; ++i)
|
||||
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + 127.5);
|
||||
for (i=1; i<255; ++i)
|
||||
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + .5);
|
||||
|
||||
gamma_table[255] = 255;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user