8. 调色板

调色板是一组离散的颜色。在GIMP中,调色板主要用于两个目的:

其实这些功能都不是主流GIMP用法:这是可以在GIMP中做到相当复杂的事情,而无需用调色板处理。尽管如此,它们仍然是高级用户应该理解的东西,即使是不太高级的用户在某些情况下也可能需要考虑它们,例如在处理 GIF 文件时。

图 7.28. 调色板对话框

调色板对话框

当您安装GIMP时,它提供了几十个预定义的调色板,您也可以创建新的调色板。一些预定义的调色板通常很有用,例如Web调色板,它包含一组被认为是网络安全的颜色;许多调色板似乎或多或少是异想天开地选择的。您可以使用调色板对话框访问所有可用的调色板。如果要创建新调色板,这也是起点。

图 7.29. 调色板编辑器

调色板编辑器

双击调色板对话框中的调色板,会调出调色板编辑器,显示您单击的调色板中的颜色。您可以使用它来使用调色板进行绘画:单击颜色将GIMP的前景色设置为该颜色,如工具箱的颜色区域所示。而另一方面,按住Ctrl键的同时单击,设置GIMP的背景色为你点击的颜色。

顾名思义,您还可以使用调色板编辑器更改调色板中的颜色,只要它是您自己创建的调色板。您不能编辑随GIMP提供的调色板;但是,您可以复制它们,然后编辑副本。

When you create palettes using the Palette Editor, they are automatically saved as soon as you exit GIMP, in the palettes folder of your personal GIMP directory. Any palette files in your directory, or in the system palettes directory created when GIMP is installed, are automatically loaded and shown in the Palettes dialog the next time you start GIMP. You can also add other folders to the palette search path using the Palette Folders page of the Preferences dialog.

GIMP调色板使用特殊文件格式,存储在扩展名为.gpl的文件中。这是一种非常简单的格式,并且它们是 ASCII 文件,因此如果您碰巧从其他来源获得调色板,并想在GIMP中使用它们, 转换它们可能并不难:只需看看任何.gpl,你会看到该怎么做。

8.1. 颜色图

令人困惑的是,GIMP使用了两种类型的调色板。更引人注目的是调色板对话框中显示的类型:调色板独立于任何图像而存在。第二种类型,索引调色板,形成索引图像的颜色图。每个索引图像都有自己的私有索引调色板,定义图像中可用的颜色集:索引调色板中允许的最大颜色数为 256。这些调色板被称为索引的,是因为每种颜色都与一个索引号相关联。(其实普通调色板中的颜色也是有编号的,只是编号没有功能意义。)

图 7.30. 颜色图对话框

颜色图对话框

The colormap of an indexed image is shown in the Indexed Palette dialog, which should not be confused with the Palettes dialog. The Palettes dialog shows a list of all of the palettes available; the Colormap dialog shows the colormap of the currently active image, if it is an indexed image – otherwise it shows nothing.

You can, however, create an ordinary palette from the colors in an indexed image—actually from the colors in any image. To do this, choose Import Palette from the right-click popup menu in the Palettes dialog: this pops up a dialog that gives you several options, including the option to import the palette from an image. (You can also import any of GIMP's gradients as a palette.) This possibility becomes important if you want to create a set of indexed images that all use the same set of colors.

将图像转换为索引模式时,该过程的主要部分是为图像创建索引调色板。这是如何发生的在第 6.6 节 “Indexed mode”中有详细描述。简而言之,您有多种方法可供选择,其中之一是使用调色板对话框中的指定调色板。

因此,综上所述,当您将图像转换为索引模式时,普通调色板可以变成索引调色板;通过将索引调色板导入调色板对话框,可以将它们转换为普通调色板。