## 第 5 章 将图像导入 GIMP

本章是关于将图像导入 GIMP。它解释了如何创建新图像、如何从文件加载图像、如何扫描它们以及如何制作屏幕截图。

但首先我们要向您介绍 GIMP 中图像的一般结构。

## 1. 图像类型

It is tempting to think of an image as something that corresponds with a single display window, or to a single file such as a JPEG file. In reality, however, a GIMP image is a complicated structure, containing a stack of layers plus several other types of objects: a selection mask, a set of channels, a set of paths, an "undo" history, etc. In this section we take a detailed look at the components of a GIMP image, and the things that you can do with them.

图像最基本的属性是它的 模式。共有三种可能的模式：RGB、灰阶和索引。RGB代表红绿蓝（Red-Green-Blue），表示图像中的每个点都用“红”色、“绿”色 、“蓝”色来表示；代表全色彩图像。每个颜色通道有 256 个可能的强度级别。颜色模型中有更多细节

在灰阶图像中，每个点由一个亮度值表示，范围从 0（黑色）到 255（白色），中间的值代表不同的灰度等级。

图 5.1. RGB 和 CMY 颜色模型的分量

在 RGB 颜色模型中，混合红色（Red）、绿色（Green）和蓝色（Blue）会产生白色，这就是屏幕上发生的情况。

在 CMY(K) 颜色模型中，混合青色（Cyan）、品红色（Magenta）和黄色（Yellow）会产生黑色，这就是在白纸上打印时发生的情况。出于经济原因和更好的显色性，打印机实际上将使用黑色墨盒。

从概念上讲，灰阶图像和 RGB 图像之间的区别在“颜色通道”的数量上：灰阶图像只有一个；RGB 图像却有三个。可以认为 RGB 图像是三个叠加的灰阶图像，一个是红色的，一个是绿色的，一个是蓝色的。

实际上，RGB 和灰阶图像都有一个额外的颜色通道，称为alpha通道，它代表不透明度。当给定图层中给定位置的 alpha 值为0时，该图层是完全透明的（您可以透过它观察），并且该位置的颜色由下面的内容决定。当 alpha 最大 (255) 时，图层是不透明的（您无法透过它观察），颜色由图层的颜色决定。中间的 alpha 值对应于不同程度的透明度/不透明度：该位置的颜色是图层颜色和下方颜色按比例混合。

图 5.2. RGB 和灰阶模式下的图像示例

RGB 模式下的图像，通道对应于红色、绿色和蓝色。

灰阶模式下的图像，通道对应于亮度。

In GIMP, in every color channel, including the alpha channel, possible values have a range depending on the image precision: 0 to 255 for a color depth of 8 bits. GIMP can load 16 and 32 bits images, and this range can be much larger.

图 5.3. 带有 Alpha 通道的图像示例

红色通道

绿色通道

蓝色通道

Alpha 通道显示那些区域为透明的图像区域。

RGB 模式下带有 Alpha 通道的彩色图像。

The third type, indexed images, is a bit more complicated to understand. In an indexed image, only a limited set of discrete colors are used, usually 256 or less (so, this indexed mode can be applied only to images with 8 bits precision). These colors form the “colormap” of the image, and each point in the image is assigned a color from the colormap. Indexed images have the advantage that they can be represented inside a computer in a way which consumes relatively little memory. As time goes on, they are used less and less, but they are still important enough to be worth supporting in GIMP. (Also, there are a few important kinds of image manipulation that are easier to implement with indexed images than with continuous-color RGB images.)

Some very commonly used types of files (including GIF and PNG) produce indexed images when they are opened in GIMP. Many of GIMP's tools don't work very well on indexed images–and many filters don't work at all–because of the limited number of colors available. Because of this, it is usually best to convert an image to RGB mode before working on it. If necessary, you can convert it back to indexed mode when you are ready to save it.

GIMP可以使用图像菜单中的模式命令轻松地从一种图像类型转换为另一种图像类型。当然，某些类型的转换（例如，RGB 到灰阶或索引）会丢失无法通过向另一个方向转换回来的信息。

| 注意
If you are trying to use a filter on an image, and the filter is disabled in the menu, usually the cause is that the image (or, more specifically, the layer) you are working on is the wrong type. Many filters can't be used on indexed images. Some can be used only on RGB images, or only on grayscale images. Some also require the presence or absence of an alpha channel. Usually the fix is to convert the image to a different type, most commonly RGB.

部分 II. 我如何成为GIMP向导？ |  | 2. 创建新文件

Report a bug in GIMP Report a documentation error