[Tutor] quick PIL question
Max Noel
maxnoel_fr at yahoo.fr
Fri Jun 3 00:49:05 CEST 2005
On Jun 2, 2005, at 23:39, Terry Carroll wrote:
> The palette mode ("P") uses a colour palette to define the actual
> colour for each pixel.
>
>
>
> Not sure what that means, exactly, but it looks like im.palette
> will get
> the palette of a a P-mode image, and im.putpalette will change it.
>
> I'm not sure how to interpret the palette once you have it,
> though. The
> description of the ImagePalette class is not too helpful.
Here's what this means. Computers nowadays use 24-bit display
modes (8 bits for each of the components R, G and B -- 32-bit display
is the same thing with an extra 8 bits of alpha/transparency). That
is, 16.7 million different possible colors.
GIF images, on the other hand, are 256-color (8-bit) images.
However, these 256 colors are not fixed: they can be any of the
regular 16.7 million.
This is where the palette comes into play. Each 256-color image
has a palette, which is basically an array of length 256, where each
element is a (24-bit RGB) color. The color data for each pixel in the
image is actually an index in this array.
Makes sense?
-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting
and sweating as you run through my corridors... How can you challenge
a perfect, immortal machine?"
More information about the Tutor
mailing list