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. To export an image with alpha transparency, you must have an alpha channel. To check if the image has an alpha channel, go to the Channels Dialog and verify that an entry for Alpha exists, besides Red, Green and Blue. If this is not the case, add a new alpha channel from the layers menu; Layer+TransparencyAdd Alpha Channel.

  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中处理图像时,背景层中的中间色调象棋格表示该导出图像的透明区域。