完全不透明的 PNG 图像可以包含 alpha 通道吗?

Can a PNG image that is entirely opaque contain an alpha channel?

是否可以构造一个完全不透明的 png 图像(这意味着图像中的每个像素都是不透明的)但图像数据本身有一个 alpha 通道?

为什么有些 PNG 图片没有 alpha 通道?

  1. 是的。就像 RGB 图像可能只包含红色通道中的数据,而不包含绿色和蓝色通道; “未使用”的频道不是问题。 Alpha 是一个独立的通道,特别是,它的值应该 独立 相关的像素颜色:“PNG 使用预乘alpha" (6.2 Alpha representation).

    有关其他详细信息,另请参阅 12.4 Alpha channel creation in the official specifications

    The alpha channel can be regarded either as a mask that temporarily hides transparent parts of the image, or as a means for constructing a non-rectangular image. In the first case, the colour values of fully transparent pixels should be preserved for future use. In the second case, the transparent pixels carry no useful data and are simply there to fill out the rectangular image area required by PNG. In this case, fully transparent pixels should all be assigned the same colour value for best compression.

  2. 因为他们不需要,根据相同的规范:

    ... PNG provides a patent-free replacement for GIF and can also replace many common uses of TIFF. Indexed-color, grayscale, and truecolor images are supported, plus an optional alpha channel. (my emphasis)