Merge "PNG decoder: handle gAMA chunk"

This commit is contained in:
Pascal Massimino 2018-01-06 00:07:58 +00:00 committed by Gerrit Code Review
commit cff38e8f4d

View File

@ -185,7 +185,6 @@ static int ExtractMetadataFromPNG(png_structp png,
}
}
}
return 1;
}
@ -265,6 +264,16 @@ int ReadPNG(const uint8_t* const data, size_t data_size,
has_alpha = !!(color_type & PNG_COLOR_MASK_ALPHA);
}
// Apply gamma correction if needed.
{
double image_gamma = 1 / 2.2, screen_gamma = 2.2;
int srgb_intent;
if (png_get_sRGB(png, info, &srgb_intent) ||
png_get_gAMA(png, info, &image_gamma)) {
png_set_gamma(png, screen_gamma, image_gamma);
}
}
if (!keep_alpha) {
png_set_strip_alpha(png);
has_alpha = 0;