*ec@sddlmZmZmZddlZejZdZdZdZdZ dZ ddd YZ d ejfd YZ ej d e d ejd dedkr ddlZddlZejeejddZejdejdndS(i(tImaget ImageFilet_binaryNicCstjd|jtS(Ns>4sI(tstructtunpacktreadt HEADERSIZE(tfobj((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pyt nextheaderscCsa|\}}|j||jd}|dkrCtdnt||d|df|S(Nits'Unknown signature, expecting 0x00000000(tseekRt SyntaxErrortread_32(Rt start_lengthtsizetstarttlengthtsig((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pytread_32ts    c Cs|\}}|j||d|d}||dkrn|j|}tjd||dddd}nStjd|d }x;tdD]-}g} |} x| dkr]|jd} | sPnt| } | d@r | d} |jd} xDt| D]} | j| qWn | d} | j|j| | | } | dkrPqqW| dkr}t d| ntjd |d j | dd dd}|j j |j |qWi|d6S( sn Read a 32bit RGB icon resource. Seems to be either uncompressed or an RLE packbits-like scheme. iiitRGBtrawii}sError reading channel [%r left]tLtN( R RRt frombuffertnewtNonetrangeti8tappendR tjointimtputband(RR RRRtsizesqtindataRtband_ixtdatat byteslefttbytet blocksizetitband((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pyR $s@  $       $cCsZ|\}}|j|tjd||j|d|ddddd}i|d6S(NRiiRtA(R RRR(RR RRRR(((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pytread_mkPs   0tIcnsFilecBseZidefdefgd6defdefgd6defdefgd6d efd efgd6Zd Zd ZdZdZ ddZ RS(tit32tt8mkitih32th8mki0til32tl8mki tis32ts8mkicCsi|_}||_t|\}}|dkrCtdnt}x`||krt|\}}|t}|t}||f||<|j|d||}qLWdS(s@ fobj is a file-like object as an icns resource ticnssnot an icns fileiN(tdctRRR RR (tselfRR5RtfilesizeR'R&((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pyt__init__ns     cCsag}xT|jjD]C\}}x4|D],\}}||jkr)|j|Pq)q)WqW|S(N(tSIZEStitemsR5R(R6tsizesRtfmtstfmttreader((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pyt itersizess  cCs+|j}|s!tdnt|S(NsNo 32bit icon resources found(R?R tmax(R6R;((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pytbestsizes cCsei}xX|j|D]I\}}|jj|}|dk r|j||j||qqW|S(s Get an icon resource as {channel: array}. Note that the arrays are bottom-up like windows bitmaps and will likely need to be flipped or transposed in some way. N(R9R5tgetRtupdateR(R6RR5tcodeR>tdesc((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pyt dataforsizes  #cCsl|dkr|j}n|j|}|jdj}y|j|dWntk rgnX|S(NRR)(RRARFRBtcopytputalphatKeyError(R6RtchannelsR((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pytgetimages  (ii(i0i0(i i (iiN( t__name__t __module__RR*R R9R8R?RARFRRK(((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pyR+Ys       t IcnsImageFilecBs,eZdZdZdZdZdZRS(s+ PIL read-only image support for Mac OS .icns files. Chooses the best resolution, but will possibly load a different size image if you mutate the size attribute before calling 'load'. The info dictionary has a key 'sizes' that is a list of sizes that the icns file has. tICNSsMac OS icns resourcecCsPt|j|_d|_|jj|_|jj|jdss.icnst__main__itrbsout.png((tPILRRRRRRRRR R*R+RNt register_opentregister_extensionRLtostsystopentargvRtsavet startfile(((s9/usr/lib64/python2.7/site-packages/PIL/IcnsImagePlugin.pyts     , R&