3 }\'&@sddlZddlmZddlmZmZmZmZddlm Z m Z m Z ddlmZmZdZdZd d Zd d ZGd ddeZGdddejZejejeeejejeejejdejejddS)N)BytesIO)Image ImageFileBmpImagePluginPngImagePlugin)i8i16lei32le)logceilz0.1sc s|jt|jjddddddddg}|j\tfd d |}t|}|jtjd t ||j t |d}x|D] }|\|jtjd dkrnd |jtjd dkrnd |jd|jd|jd|jtjd dt }|j }|j |tj|j|d|jd |j}t |} |jtjd| |jtjd||j } |j||j||| }|j| q~WdS)Nsizes 0@cs8|dks0|dks0|ddks0|ddkr4dSdS)NrrrFT)x)heightwidthrj/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-i584jbuk/Pillow/PIL/IcoImagePlugin.py0sz_save..zr)rrrrrsz"IcoFile.__init__..)keycSs|dS)Nr@r)rrrrrs)rr)r*r4 SyntaxErrorbufentryi16Znb_itemsrangeri32r r appendsortedreverse)selfrCsiZ icon_headerjrrr__init__Us<          zIcoFile.__init__cCsdd|jDS)zJ Get a list of all available icon sizes and color depths. cSsh|]}|d|dfqS)rrr).0hrrr sz IcoFile.sizes..)rD)rKrrrr sz IcoFile.sizesFcCsLx@t|jD]2\}}||dkr |dks4||dkr |j|Sq W|jdS)z, Get an image from the icon r?Fr>r) enumeraterDframe)rKr r=rMrQrrrgetimages zIcoFile.getimagec Cs|j|}|jj|d|jjd}|jj|d|ddtjkrXtj|j}ntj|j}|j dt |j ddf|_ |j d\}}}}|d|j ||f|j d<|d} d} x(tj jD]\} } | | dkr| } PqWd| kr8|jj||jj|j d|j ddd dd} tjd |j | d d}n|j d}|ddkrf|d|j dd7}|t |j d|j d| d }t ||j dd}|jj||jj|}tjd |j |d dt |ddf}|jd}|j||S)z- Get an image from frame idx r.r9Nrrr7rr2r8Lrawg @1z1;IZRGBA)rr)rVrrYrY)rDrCr)r*rrZ PngImageFilerZ DibImageFiler int_sizeZtileZBIT2MODEitemsrZ frombufferconvertZputalpha)rKidxheaderdatar+deoamoder=kvZ alpha_bytesmaskwZand_mask_offset total_bytesZ mask_datarrrrTsT      *     z IcoFile.frameN)F)__name__ __module__ __qualname__rOr rUrTrrrrr5Ts7 r5c@sJeZdZdZdZdZddZeddZej ddZd d Z d d Z d S) IcoImageFilea9 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. 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|_|jj|jd<|jjdd|_|jdS)Nr rr?)r5r,icor inforDr load)rKrrr_opens zIcoImageFile._opencCs|jS)N)r[)rKrrrr szIcoImageFile.sizecCs ||jdkrtd||_dS)Nr z2This is not one of the allowed sizes of this image)rp ValueErrorr[)rKvaluerrrr scCs2|jj|j}|j|j|_|j|_|j|_dS)N)rorUr rqr+re)rKr+rrrrqs zIcoImageFile.loadcCsdS)Nr)rKrrr load_seekszIcoImageFile.load_seekN) rkrlrm__doc__formatformat_descriptionrrpropertyr setterrqrurrrrrns rnz.icoz image/x-icon)r#iorrrrr_binaryrr rEr rGmathr r __version__rr1r4objectr5rnZ register_openrwZ register_saveZregister_extensionZ register_mimerrrrs & 4