2.3. 保存带有透明度的图像

There are two different approaches used by graphic file formats for supporting transparent image areas: simple binary transparency and alpha transparency. Simple binary transparency is supported in the GIF format; one color from the indexed color palette is marked as the transparent color. Alpha transparency is supported in the PNG format; the transparency information is stored in a separate channel, the Alpha channel.

[注意] 注意

GIF 格式很少使用,因为 PNG 支持 GIF 的所有功能以及附加功能(例如,alpha 透明度)。尽管如此,GIF 仍然用于动画。

过程 6.1. 创建具有透明区域(Alpha 透明度)的图像

  1. 首先,我们将使用与之前教程中相同的图像,即 GIMP 吉祥物 Wilber。

    图 6.4. 以 RGBA 模式打开的 Wilber 图像

    以 RGBA 模式打开的 Wilber 图像

  2. 要导出具有 Alpha 透明度的图像,您必须具有 Alpha 通道。要检查图像是否具有 Alpha 通道,请转到通道对话框并验证除了红色、绿色和蓝色,名为Alpha的条目是否存在。如果不是这种情况,请从图层菜单中添加一个新的 Alpha 通道图层+透明度添加Alpha通道

  3. 原始 XCF 文件包含您可以删除的背景层。GIMP带有支持创建渐变的标准滤镜;查看滤镜+光照和阴影。你只受你的想象力的限制。为了演示 alpha 透明度的功能,在 Wilber 周围背景中显示了柔和光晕。

  4. After you're done with your image, you can export it in PNG format.

图 6.5. 带有透明度的Wilber图像

带有透明度的Wilber图像

当您在GIMP中处理图像时,背景层中的中间色调象棋格表示该导出图像的透明区域。