ó <×ï[c@sœddlZddlmZmZmZmZdefd„ƒYZd„Zd„Z d„Z d d „Z d d „Z d d „Z d d„Zd„ZdS(iÿÿÿÿNi(t ImageColortGimpPaletteFiletGimpGradientFilet PaletteFilet ImagePalettecBsSeZdZdd dd„Zd„Zd„Zd„ZeZd„Z d„Z RS( ss Color palette for palette mapped images :param mode: The mode to use for the Palette. See: :ref:`concept-modes`. Defaults to "RGB" :param 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 in ``mode``. The list must be aligned by channel (All R values must be contiguous in the list before G and B values.) Defaults to 0 through 255 per channel. :param size: An optional palette size. If given, it cannot be equal to or greater than 256. Defaults to 0. tRGBicCs®||_d|_|p4ttdƒƒt|jƒ|_i|_d|_|dkrzt|jƒdt|jƒks›|dkrª|t|jƒkrªt dƒ‚ndS(Niiswrong palette size( tmodetNonetrawmodet bytearraytrangetlentpalettetcolorstdirtyt ValueError(tselfRR tsize((s0/tmp/pip-build-SKekGm/pillow/PIL/ImagePalette.pyt__init__&s  (  .!cCsbtƒ}|j|_|j|_|jdk r@|j|_n|jjƒ|_|j|_|S(N(RRRR RR tcopyR(Rtnew((s0/tmp/pip-build-SKekGm/pillow/PIL/ImagePalette.pyR0s    cCs0|jr|j|jfS|jd|jƒfS(s£ Get palette contents in format suitable for the low-level ``im.putpalette`` primitive. .. warning:: This method is experimental. s;L(RR Rttobytes(R((s0/tmp/pip-build-SKekGm/pillow/PIL/ImagePalette.pytgetdata<s cCsi|jrtdƒ‚nt|jtƒr1|jStjd|jƒ}t|dƒr_|jƒS|jƒS(sUConvert palette to bytes. .. warning:: This method is experimental. s!palette contains raw palette datatBR( RRt isinstanceR tbytestarraythasattrRttostring(Rtarr((s0/tmp/pip-build-SKekGm/pillow/PIL/ImagePalette.pyRGs  cCs|jrtdƒ‚nt|tƒrðy|j|SWqtk rìt|jtƒrmt|jƒ|_nt |jƒ}|dkr—tdƒ‚n||j|<|d|j|<|d|j|d<|d|j|dR R R2R(RR>R R*((s0/tmp/pip-build-SKekGm/pillow/PIL/ImagePalette.pyR?­s s#fff0c0cCsZtj|ƒ\}}}td|ƒ}td|ƒ}td|ƒ}td|||ƒS(NiR(RtgetrgbR7R(R5trtgtb((s0/tmp/pip-build-SKekGm/pillow/PIL/ImagePalette.pytsepiaµs cCs#t|ttdƒƒt|ƒƒS(Ni(RR;R R (R((s0/tmp/pip-build-SKekGm/pillow/PIL/ImagePalette.pytwedge½sc Cs’t|dƒ}}xstjtjtjgD]M}y-|jdƒ||ƒjƒ}|r]PnWq+ttfk rwq+Xq+Wtdƒ‚WdQX|S(Ntrbiscannot load palette( R%RRRtseekt getpalettet SyntaxErrorRtIOError(tfilenameR)tpaletteHandlerR6((s0/tmp/pip-build-SKekGm/pillow/PIL/ImagePalette.pytloadÁs (RtRRRRtobjectRR1R7R:R=R?RDRERM(((s0/tmp/pip-build-SKekGm/pillow/PIL/ImagePalette.pyts "t