Add support for loading images with associated alpha.
This commit is contained in:
parent
4e9839d453
commit
95046512a4
2
png.h
2
png.h
@ -2819,6 +2819,8 @@ typedef struct
|
|||||||
# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */
|
# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PNG_FORMAT_FLAG_ASSOCIATED_ALPHA 0x40U /* alpha channel is associated */
|
||||||
|
|
||||||
/* Commonly used formats have predefined macros.
|
/* Commonly used formats have predefined macros.
|
||||||
*
|
*
|
||||||
* First the single byte (sRGB) formats:
|
* First the single byte (sRGB) formats:
|
||||||
|
10
pngread.c
10
pngread.c
@ -3760,6 +3760,12 @@ png_image_read_direct(png_voidp argument)
|
|||||||
output_gamma = PNG_DEFAULT_sRGB;
|
output_gamma = PNG_DEFAULT_sRGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((change & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0)
|
||||||
|
{
|
||||||
|
mode = PNG_ALPHA_OPTIMIZED;
|
||||||
|
change &= ~PNG_FORMAT_FLAG_ASSOCIATED_ALPHA;
|
||||||
|
}
|
||||||
|
|
||||||
/* If 'do_local_background' is set check for the presence of gamma
|
/* If 'do_local_background' is set check for the presence of gamma
|
||||||
* correction; this is part of the work-round for the libpng bug
|
* correction; this is part of the work-round for the libpng bug
|
||||||
* described above.
|
* described above.
|
||||||
@ -3985,6 +3991,10 @@ png_image_read_direct(png_voidp argument)
|
|||||||
else if (do_local_compose != 0) /* internal error */
|
else if (do_local_compose != 0) /* internal error */
|
||||||
png_error(png_ptr, "png_image_read: alpha channel lost");
|
png_error(png_ptr, "png_image_read: alpha channel lost");
|
||||||
|
|
||||||
|
if ((format & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0) {
|
||||||
|
info_format |= PNG_FORMAT_FLAG_ASSOCIATED_ALPHA;
|
||||||
|
}
|
||||||
|
|
||||||
if (info_ptr->bit_depth == 16)
|
if (info_ptr->bit_depth == 16)
|
||||||
info_format |= PNG_FORMAT_FLAG_LINEAR;
|
info_format |= PNG_FORMAT_FLAG_LINEAR;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user