SV: PIL - gif image

Simon Dahlbacka sdahlbac at abo.fi
Thu Jan 9 12:13:28 EST 2003


yes, it was just how to get access to what was in the .palette attribute I
wasn't sure about.. but anyhow, I did like this..

    def indextoRGB(self,im,index):
        return (ord(im.palette.data[3*index]),
        ord(im.palette.data[3*index+1]),
        ord(im.palette.data[3*index+2]))

..but maybe there's an easier way?


Erik Max Francis <max at alcyone.com> skrev i
diskussionsgruppsmeddelandet:3E1CD6FA.B66F4C09 at alcyone.com...
> Simon Dahlbacka wrote:
>
> > I don't know if there's something I've missed in the docs or what, but
> > how
> > do I translate the index I get from getpixel(xy) into a real color,
> > i.e. rgb
> > values? I'm trying to get hold of the real color values of
> > particular
> > pixel in a paletted image.. (gif)
>
> Check the .palette attribute, which for an image with mode 'P' will be
> an instance of an ImagePalette.
>
> --
>  Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
>  __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
> /  \ Strange is our situation here upon earth.
> \__/ Albert Einstein
>     ZOE / http://www.alcyone.com/pyos/zoe/
>  A simple Python OpenGL rendering engine.






More information about the Python-list mailing list