Changing name of has_transpareny_in_palette to has_transparency_in_tRNS
This function checks for transparency info in the tRNS chunk Other images besides paletted images can have tRNS chunks, including Gray8 and RGB has_transparency_in_tRNS is a better name for the function BUG=skia: Review URL: https://codereview.chromium.org/1224453002
This commit is contained in:
parent
5b4f05f709
commit
21cea726e7
@ -100,8 +100,9 @@ private:
|
|||||||
};
|
};
|
||||||
#define AutoCleanPng(...) SK_REQUIRE_LOCAL_VAR(AutoCleanPng)
|
#define AutoCleanPng(...) SK_REQUIRE_LOCAL_VAR(AutoCleanPng)
|
||||||
|
|
||||||
// call only if color_type is PALETTE. Returns true if the ctable has alpha
|
//checks if there is transparency info in the tRNS chunk
|
||||||
static bool has_transparency_in_palette(png_structp png_ptr,
|
//image types which could have data in the tRNS chunk include: Index8, Gray8, RGB
|
||||||
|
static bool has_transparency_in_tRNS(png_structp png_ptr,
|
||||||
png_infop info_ptr) {
|
png_infop info_ptr) {
|
||||||
if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
|
if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
|
||||||
return false;
|
return false;
|
||||||
@ -287,11 +288,11 @@ static bool read_header(SkStream* stream, png_structp* png_ptrp,
|
|||||||
switch (colorType) {
|
switch (colorType) {
|
||||||
case PNG_COLOR_TYPE_PALETTE:
|
case PNG_COLOR_TYPE_PALETTE:
|
||||||
skColorType = kIndex_8_SkColorType;
|
skColorType = kIndex_8_SkColorType;
|
||||||
skAlphaType = has_transparency_in_palette(png_ptr, info_ptr) ?
|
skAlphaType = has_transparency_in_tRNS(png_ptr, info_ptr) ?
|
||||||
kUnpremul_SkAlphaType : kOpaque_SkAlphaType;
|
kUnpremul_SkAlphaType : kOpaque_SkAlphaType;
|
||||||
break;
|
break;
|
||||||
case PNG_COLOR_TYPE_RGB:
|
case PNG_COLOR_TYPE_RGB:
|
||||||
if (has_transparency_in_palette(png_ptr, info_ptr)) {
|
if (has_transparency_in_tRNS(png_ptr, info_ptr)) {
|
||||||
//convert to RGBA with tranparency information in tRNS chunk if it exists
|
//convert to RGBA with tranparency information in tRNS chunk if it exists
|
||||||
png_set_tRNS_to_alpha(png_ptr);
|
png_set_tRNS_to_alpha(png_ptr);
|
||||||
skAlphaType = kUnpremul_SkAlphaType;
|
skAlphaType = kUnpremul_SkAlphaType;
|
||||||
@ -303,7 +304,7 @@ static bool read_header(SkStream* stream, png_structp* png_ptrp,
|
|||||||
skColorType = kN32_SkColorType;
|
skColorType = kN32_SkColorType;
|
||||||
break;
|
break;
|
||||||
case PNG_COLOR_TYPE_GRAY:
|
case PNG_COLOR_TYPE_GRAY:
|
||||||
if (has_transparency_in_palette(png_ptr, info_ptr)) {
|
if (has_transparency_in_tRNS(png_ptr, info_ptr)) {
|
||||||
//FIXME: support gray with alpha as a color type
|
//FIXME: support gray with alpha as a color type
|
||||||
//convert to RGBA if there is transparentcy info in the tRNS chunk
|
//convert to RGBA if there is transparentcy info in the tRNS chunk
|
||||||
png_set_tRNS_to_alpha(png_ptr);
|
png_set_tRNS_to_alpha(png_ptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user