B ¥.¦^–'ã@sÊddlZddlZddlmZddlmZmZddlmZm Z m Z m Z ddl m Z mZmZdZdd „Zd d „ZGd d „d ƒZGdd„de j ƒZe  ejee¡e  eje¡e  ejd¡e  ejd¡dS)éN)ÚBytesIO)ÚceilÚlogé)ÚBmpImagePluginÚImageÚ ImageFileÚPngImagePlugin)Úi8Úi16leÚi32lesc s˜| t¡|j ddddddddg¡}|j\‰‰t‡‡fd d „|ƒ}t|ƒ}| t d t |ƒ¡¡|  ¡t |ƒd }x|D]}|\‰‰| t d ˆdkr¢ˆnd¡¡| t d ˆdkrÀˆnd¡¡| d¡| d¡| d¡| t d d¡¡t ƒ}|  ¡}|j |tjdd| |d¡| d¡| ¡}t |ƒ} | t d| ¡¡| t d|¡¡|  ¡} | |¡| |¡|| }| | ¡q~WdS)NÚsizes)ér)ér)é r)é0r)é@r)é€r)ércs8|dˆks0|dˆks0|ddks0|ddkr4dSdS)NrrrFT©)Úx)ÚheightÚwidthrú6/tmp/pip-install-mwhup7aw/Pillow/PIL/IcoImagePlugin.pyÚ/s4z_save..zr)rrrrr‹óz"IcoFile.__init__..)ÚkeycSs|dS)Nr@r)rrrrrŽrA)r*r4Ú SyntaxErrorÚbufÚentryÚi16Znb_itemsÚranger Úi32rrÚappendÚsortedÚreverse)ÚselfrDÚsÚiZ icon_headerÚjrrrÚ__init__Ws:          zIcoFile.__init__cCsdd„|jDƒS)zJ Get a list of all available icon sizes and color depths. cSsh|]}|d|df’qS)rrr)Ú.0Úhrrrú •sz IcoFile.sizes..)rE)rLrrrr ‘sz IcoFile.sizesFcCs@x:t|jƒD],\}}||dkr |dks4||dkr |Sq WdS)Nr?Fr>r)Ú enumeraterE)rLr r=rNrRrrrÚ getentryindex—s zIcoFile.getentryindexcCs| | ||¡¡S)z, Get an image from the icon )ÚframerU)rLr r=rrrÚgetimageszIcoFile.getimagec Csþ|j|}|j |d¡|j d¡}|j |d¡|dd…tjkrXt |j¡}n¢t |j¡}t   |j ¡|j dt |j ddƒf|_ |jd\}}}}|d|j ||f|jd<|d} d} x(tj ¡D]\} } | | dkrÐ| } PqÐWd| krD|j |¡|j |j d|j dd ¡d dd …} t  d |j | d d ¡}n¢|j d}|ddkrr|d|j dd7}|t |j d|j d| dƒ}t ||j ddƒ}|j |¡|j |¡}t  d|j |d dt |dƒdf¡}| d¡}| |¡|S)z- Get an image from frame idx r.r9Nrrr7)rrrr2r8ÚLÚraw)rXréÿÿÿÿg @Ú1z1;IrZZRGBA)rErDr)r*r rZ PngImageFilerZ DibImageFilerZ_decompression_bomb_checkr ÚintÚ_sizeZtileZBIT2MODEÚitemsZ frombufferÚconvertZputalpha)rLÚidxÚheaderÚdatar+ÚdÚeÚoÚaÚmoder=ÚkÚvZ alpha_bytesÚmaskÚwZand_mask_offsetÚ total_bytesZ mask_datarrrrV£sT       * $    z IcoFile.frameN)F)F)Ú__name__Ú __module__Ú __qualname__rPr rUrWrVrrrrr5Vs :  r5c@sJeZdZdZdZdZdd„Zedd„ƒZej dd„ƒZd d „Z d d „Z d S)Ú IcoImageFileaš PIL read-only image support for Microsoft Windows .ico files. By default the largest resolution image in the file will be loaded. This can be changed by altering the 'size' attribute before calling 'load'. The info dictionary has a key 'sizes' that is a list of the sizes available in the icon file. Handles classic, XP and Vista icon formats. When saving, PNG compression is used. Support for this was only added in Windows Vista. This plugin is a refactored version of Win32IconImagePlugin by Bryan Davis . https://code.google.com/archive/p/casadebender/wikis/Win32IconImagePlugin.wiki ZICOz Windows IconcCs:t|jƒ|_|j ¡|jd<|jjdd|_| ¡dS)Nr rr?)r5r,Úicor ÚinforEr Úload)rLrrrÚ_opens zIcoImageFile._opencCs|jS)N)r])rLrrrr szIcoImageFile.sizecCs ||jdkrtdƒ‚||_dS)Nr z2This is not one of the allowed sizes of this image)rrÚ ValueErrorr])rLÚvaluerrrr scCs”|jr|jj|jkrdS|j |j¡}| ¡|j|_|j|_|j|jkrt d¡|j |j¡}t |j dƒ}|j||<t |ƒ|j d<|j|_dS)NzImage was not the expected sizer ) r+r rqrWrsrgÚwarningsÚwarnrUr"rrÚset)rLr+Úindexr rrrrs#s   zIcoImageFile.loadcCsdS)Nr)rLrrrÚ load_seek6szIcoImageFile.load_seekN) rmrnroÚ__doc__ÚformatÚformat_descriptionrtÚpropertyr Úsetterrsr{rrrrrpüs rpz.icoz image/x-icon)r#rwÚiorÚmathrrÚrrrr Ú_binaryr r rFr rHrr1r4r5rpZ register_openr}Z register_saveZregister_extensionZ register_mimerrrrÚs +'D