ImagePalette Module
The ImagePalette
module contains a class of the same name torepresent the color palette of palette mapped images.
注解
This module was never well-documented. It hasn’t changed since 2001,though, so it’s probably safe for you to read the source code and puzzleout the internals if you need to.
The ImagePalette
class has several methods,but they are all marked as “experimental.” Read that as you will. The[source]
link is there for a reason.
- class
PIL.ImagePalette.
ImagePalette
(mode='RGB', palette=None, size=0)[源代码] - Color palette for palette mapped images
参数:
- mode – The mode to use for the Palette. See:模式. Defaults to “RGB”
- palette – An optional palette. If given, it must be a bytearray,an array or a list of ints between 0-255 and of length
size
times the number of colors inmode
. The list must be alignedby channel (All R values must be contiguous in the list before Gand B values.) Defaults to 0 through 255 per channel. - size – An optional palette size. If given, it cannot be equal toor greater than 256. Defaults to 0.
getcolor
(color)[源代码]- Given an rgb tuple, allocate palette entry.
警告
This method is experimental.
getdata
()[源代码]- Get palette contents in format suitable # for the low-level
im.putpalette
primitive.
警告
This method is experimental.
save
(fp)[源代码]- Save palette to text file.
警告
This method is experimental.
tobytes
()[源代码]- Convert palette to bytes.
警告
This method is experimental.
警告
This method is experimental.
当前内容版权归 pillow-zh-cn 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 pillow-zh-cn .