Lines Matching full:alpha
614 * image has alpha or transparency, and png_handle_alpha()[*] has been
626 * alpha channel or a transparency chunk, you must provide a buffer for
678 /* Read the entire image. If the image has an alpha channel or a tRNS
1066 /* Strip alpha
1098 * Expand paletted or RGB images with transparency to full alpha
1157 /* Invert the alpha channel from opacity to transparency */
1245 #define PNG_CMAP_GA 1 /* Process GA data to a color-map with alpha */
1698 png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha,
1703 * file and alpha are 8-bit values. The (output) encoding will always be
1709 /* The alpha is always an 8-bit value (it comes from the palette), the value
1712 f = f * alpha + b * (255-alpha);
1736 png_uint_32 alpha, int encoding)
1771 alpha *= 257;
1792 alpha *= 257;
1805 alpha *= 257;
1827 alpha = PNG_DIV257(alpha);
1839 alpha = PNG_DIV257(alpha);
1867 /* The linear 16-bit values must be pre-multiplied by the alpha channel
1869 * if the alpha channel is removed.)
1874 entry[afirst ? 0 : 3] = (png_uint_16)alpha;
1878 if (alpha < 65535)
1880 if (alpha > 0)
1882 blue = (blue * alpha + 32767U)/65535U;
1883 green = (green * alpha + 32767U)/65535U;
1884 red = (red * alpha + 32767U)/65535U;
1896 entry[1 ^ afirst] = (png_uint_16)alpha;
1900 if (alpha < 65535)
1902 if (alpha > 0)
1903 green = (green * alpha + 32767U)/65535U;
1925 entry[afirst ? 0 : 3] = (png_byte)alpha;
1933 entry[1 ^ afirst] = (png_byte)alpha;
1980 /* Alpha is retained, the output will be a color-map with entries
1981 * selected by six levels of alpha. One transparent entry, 6 gray
1982 * levels for all the intermediate alpha values, leaving 230 entries
1987 * if (alpha > 229) // opaque
1993 * else if (alpha < 26) // transparent
2000 * base = 226 + 6 * PNG_DIV51(alpha);
2090 png_ptr->num_trans > 0) /* alpha in input */ &&
2091 ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) /* no alpha in output */)
2098 "a background color must be supplied to remove alpha/transparency");
2168 * value or, if the output has no alpha, the background color.
2196 * there is an alpha channel (back_alpha == 0), but it does no
2225 * special processing; add an alpha channel, sacrifice gray level
2226 * 254 and convert transparent (alpha==0) entries to that.
2233 * If the output has no alpha channel *and* the background color is
2279 /* NOTE: does this work without expanding tRNS to alpha?
2324 /* 8-bit or 16-bit PNG with two channels - gray and alpha. A minimum
2325 * of 65536 combinations. If, however, the alpha channel is to be
2331 * worry about tRNS matching - tRNS is ignored if there is an alpha
2339 png_error(png_ptr, "gray+alpha color-map: too few entries");
2347 else /* alpha is removed */
2349 /* Alpha must be removed as the PNG data is processed when the
2357 * level color values, one set for each intermediate alpha value.
2373 png_error(png_ptr, "gray-alpha color-map: too few entries");
2407 png_error(png_ptr, "ga-alpha color-map: too few entries");
2443 * used when alpha != 0
2455 * by an 8-bit alpha value (0..255).
2457 png_uint_32 alpha = 51 * a;
2458 png_uint_32 back_rx = (255-alpha) * back_r;
2459 png_uint_32 back_gx = (255-alpha) * back_g;
2460 png_uint_32 back_bx = (255-alpha) * back_b;
2464 png_uint_32 gray = png_sRGB_table[g*51] * alpha;
2498 /* The output will now be one or two 8-bit gray or gray+alpha
2499 * channels. The more complex case arises when the input has alpha.
2505 /* Both input and output have an alpha channel, so no background
2521 /* Either the input or the output has no alpha channel, so there
2529 alpha channel is to be removed we will hit the
2547 /* But if the input has alpha or transparency it must be removed
2613 * color or alpha; png_quantize ignores alpha. Easier overall just
2619 /* Is there any transparency or alpha? */
2623 /* Is there alpha in the output too? If so all four channels are
2624 * processed into a special RGB cube with alpha support.
2631 png_error(png_ptr, "rgb+alpha color-map: too few entries");
2644 /* Add 27 r,g,b entries each with alpha 0.5. */
2668 /* Alpha/transparency must be removed. The background must
2680 png_error(png_ptr, "rgb-alpha color-map: too few entries");
2716 * the background at alpha 0.5.
2759 else /* no alpha or transparency in the input */
2761 /* Alpha in the output is irrelevant, simply map the opaque input
2993 unsigned int alpha = *inrow++;
3000 if (alpha > 229) /* opaque */
3004 else if (alpha < 26) /* transparent */
3010 entry = 226 + 6 * PNG_DIV51(alpha) + PNG_DIV51(gray);
3021 png_byte alpha = *inrow++;
3023 if (alpha == 0)
3045 unsigned int alpha = inrow[3];
3047 /* Because the alpha entries only hold alpha==0.5 values
3048 * split the processing at alpha==0.25 (64) and 0.75
3052 if (alpha >= 196)
3056 else if (alpha < 64)
3075 * So, as above with the explicit alpha checks, the
3308 png_byte alpha = inrow[channels];
3310 if (alpha > 0) /* else no change to the output */
3318 if (alpha < 255) /* else just use component */
3327 component += (255-alpha)*png_sRGB_table[outrow[c]];
3340 inrow += channels+1; /* components and alpha channel */
3359 * happening inside libpng, so this routine sees an 8 or 16-bit gray+alpha
3360 * row and handles the removal or pre-multiplication of the alpha channel.
3377 * might be 8 or 16-bit but should always have two channels; gray plus alpha.
3388 /* Expect the 8-bit case to always remove the alpha channel */
3415 /* 8-bit sRGB gray values with an alpha channel; the alpha channel is
3466 png_byte alpha = inrow[1];
3468 if (alpha > 0) /* else no change to the output */
3472 if (alpha < 255) /* else just use component */
3476 * function and multiply the alpha out.
3478 component = png_sRGB_table[component] * alpha;
3480 (255-alpha);
3487 inrow += 2; /* gray and alpha channel */
3511 png_byte alpha = inrow[1];
3513 if (alpha > 0) /* else use background */
3517 if (alpha < 255) /* else just use component */
3519 component = png_sRGB_table[component] * alpha;
3520 component += background * (255-alpha);
3530 inrow += 2; /* gray and alpha channel */
3541 /* 16-bit linear with pre-multiplied alpha; the pre-multiplication must
3542 * still be done and, maybe, the alpha channel removed. This code also
3543 * handles the alpha-first option.
3606 png_uint_16 alpha = inrow[1];
3608 if (alpha > 0) /* else 0 */
3610 if (alpha < 65535) /* else just use component */
3612 component *= alpha;
3623 outrow[1 ^ swap_alpha] = alpha;
3625 inrow += 2; /* components and alpha channel */
3669 int mode; /* alpha mode */
3722 /* If there *is* an alpha channel in the input it must be multiplied
3726 mode = PNG_ALPHA_STANDARD; /* associated alpha */
3780 /* Now the background/alpha channel changes. */
3783 /* Removing an alpha channel requires composition for the 8-bit
3789 /* If RGB->gray is happening the alpha channel must be left and the
3826 /* This leaves the alpha channel in the output, so it has to be
3835 else /* output needs an alpha channel */
3839 * alpha channel (weird API), so it must be added in the correct
3869 /* Now set the alpha mode correctly; this is always done, even if there is
3870 * no alpha channel in either the input or the output because it correctly
3894 /* Only relevant if there is an alpha channel - it's particularly
3896 * be set above and then libpng will keep the alpha channel for this
3963 png_error(png_ptr, "png_image_read: alpha channel lost");
3985 png_error(png_ptr, "unexpected alpha swap transformation");