zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
U
T±dÌ.ã@sêddlZddlmZddlmZmZddlmZmZm    Z    m
Z
ddl m Z ddl mZddl mZdd    l mZdd
l mZd Zd d „Zdd„ZGdd„dƒZGdd„de    j    ƒZe ejee¡e eje¡e ejd¡e ejd¡dS)éN)ÚBytesIO)ÚceilÚlogé)ÚBmpImagePluginÚImageÚ    ImageFileÚPngImagePlugin)Úi16le)Úi32le)Úo8)Úo16le)Úo32lesc
Csö| t¡|j d¡dk}|j ddddddd    d
g¡}g}|g|j d g¡}|j\}}tt|ƒƒD]Þ}    |    d |ksd|    d |ksd|    d dksd|    d dkršqd|D]|}
|
j|    kr®qž| |
¡|rtj    |
j
d } | g} |D]<} | j|    krèqØtj    | j
d } | | krØ| | ¡|  | ¡qØqdqž|
  ¡}|j |    t jjdd| |¡qd| tt|ƒƒ¡| ¡t|ƒd}|D]€}|j\}}| t|dkr’|nd ƒ¡| t|dkr®|nd ƒ¡|rÐtj    |j
d d…nd\} }| t|ƒ¡| d¡| d¡| t| ƒ¡tƒ}|rT| |d¡| dkr`t  d|    ¡}t ||dd|    d dfg¡n | |d¡| d ¡| ¡}|rœ|dd…t|dƒ|dd…}t|ƒ}| t|ƒ¡| t|ƒ¡| ¡}| |¡| |¡||}| |¡qndS)NZ bitmap_formatÚbmpÚsizes)ér)ér)é r)é0r)é@r)é€r)érZ append_imagesrrr)Z reducing_gapr)rrósZdibrÚ1Úraw©rr)rréÿÿÿÿZpngééé )ÚwriteÚ_MAGICZ encoderinfoÚgetÚsizeÚsortedÚsetÚappendrZSAVEÚmodeÚcopyZ    thumbnailrZ
ResamplingZLANCZOSÚo16ÚlenÚtellr rÚsaveÚnewrÚ_saveÚseekÚreadÚo32)ÚimÚfpÚfilenamerrÚframesZ provided_imsÚwidthÚheightr#Z provided_imÚbitsZ    bits_usedZother_imÚframeÚoffsetÚcolorsZimage_ioZand_maskZ image_bytesZ    bytes_lenÚcurrent©r=úId:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PIL/IcoImagePlugin.pyr.*s€
þ
0
 
 
 
 
 
"
 
 
 ÿ 
$
 
r.cCs|dd…tkS)Né)r!)Úprefixr=r=r>Ú_acceptusrAc@s8eZdZdd„Zdd„Zd dd„Zddd    „Zd
d „Zd S)ÚIcoFilec Cs@| d¡}t|ƒsd}t|ƒ‚||_g|_t|dƒ|_t|jƒD]È}| d¡}|d|d|d|dt|dƒt|dƒt|d    ƒt|d
ƒd œ}d D]}||sd ||<q|dpÎ|ddkrÌt    t
|ddƒƒpÎd |d<|d|df|d<|d|d|d<|j  |¡q@t |jdd„d|_t |jdd„d|_|j  ¡dS)zL
        Parse image from file-like object containing ico file data
        éznot an ICO filer?rrrrérr)r6r7Únb_colorÚreservedZplanesÚbppr#r:©r6r7rrGrEÚ color_depthr6r7ÚdimÚsquarecSs|dS)NrIr=©Úxr=r=r>Ú<lambda>¯óz"IcoFile.__init__.<locals>.<lambda>)ÚkeycSs|dS)NrKr=rLr=r=r>rN²rON)r0rAÚ SyntaxErrorÚbufÚentryÚi16Znb_itemsÚrangeÚi32rrr&r$Úreverse)ÚselfrRÚsÚmsgÚiZ icon_headerÚjr=r=r>Ú__init__zsB
 
ø 
 ýú    zIcoFile.__init__cCsdd„|jDƒS)zJ
        Get a list of all available icon sizes and color depths.
        cSsh|]}|d|df’qSrHr=)Ú.0Úhr=r=r>Ú    <setcomp>¹sz IcoFile.sizes.<locals>.<setcomp>)rS©rXr=r=r>rµsz IcoFile.sizesFcCs@t|jƒD]0\}}||dkr
|dks2||dkr
|Sq
dS)NrJFrIr)Ú    enumeraterS)rXr#rGr[r_r=r=r>Ú getentryindex»s 
zIcoFile.getentryindexcCs| | ||¡¡S)z,
        Get an image from the icon
        )r9rc)rXr#rGr=r=r>ÚgetimageÁszIcoFile.getimagec
CsÌ|j|}|j |d¡|j d¡}|j |d¡|dd…tjkrdt |j¡}t |j    ¡ndt
  |j¡}t |j    ¡|j    dt |j    ddƒf|_ |jd\}}}}|d|j    ||f|jd<|d}    d    |    kr"|j |¡|j |j    d|j    dd
¡d dd
…}
t d |j    |
d d¡} n’|j    d} | d    dkrP| d    |j    dd    7} t | |j    ddƒ} |d|d| }|j |¡|j | ¡}t d|j    |d dt | dƒdf¡} | d¡}| | ¡|S)z-
        Get an image from frame idx
        r:rNrrrrrGrr?rDÚLr)rerrr#rz1;IrZRGBA)rSrRr/r0r    r!Z PngImageFilerZ_decompression_bomb_checkr#rZ DibImageFileÚintÚ_sizeZtileZ
frombufferÚconvertZputalpha)rXÚidxÚheaderÚdatar2ÚdÚeÚoÚarGZ alpha_bytesÚmaskÚwÚ total_bytesZand_mask_offsetZ    mask_datar=r=r>r9ÇsP
 
 *û    
  û
 
z IcoFile.frameN)F)F)Ú__name__Ú
__module__Ú __qualname__r]rrcrdr9r=r=r=r>rBys
;
 
rBc@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. If you are unable to view the icon in Windows, convert the
    image to "RGBA" mode before saving.
 
    This plugin is a refactored version of Win32IconImagePlugin by Bryan Davis
    <casadebender@gmail.com>.
    https://code.google.com/archive/p/casadebender/wikis/Win32IconImagePlugin.wiki
    ZICOz Windows IconcCs:t|jƒ|_|j ¡|jd<|jjdd|_| ¡dS)NrrrJ)rBr3ÚicorÚinforSr#Úloadrar=r=r>Ú_open3s zIcoImageFile._opencCs|jS©N)rgrar=r=r>r#9szIcoImageFile.sizecCs$||jdkrd}t|ƒ‚||_dS)Nrz2This is not one of the allowed sizes of this image)rxÚ
ValueErrorrg)rXÚvaluerZr=r=r>r#=scCs¦|jdk    r$|jj|jkr$tj |¡S|j |j¡}| ¡|j|_d|_|j|_|j|jkr¢t     d¡|j 
|j¡}t |j dƒ}|j||<t |ƒ|j d<|j|_dS)NzImage was not the expected sizer)r2r#rryrwrdZpyaccessr'ÚwarningsÚwarnrcÚlistrxr%)rXr2Úindexrr=r=r>ryDs  
 
zIcoImageFile.loadcCsdSr{r=rar=r=r>Ú    load_seekXszIcoImageFile.load_seekN) rsrtruÚ__doc__ÚformatÚformat_descriptionrzÚpropertyr#Úsetterryr‚r=r=r=r>rvs
 
rvz.icoz image/x-icon)r~ÚiorÚmathrrÚrrrr    Ú_binaryr
rTr rVr r r)rr1r!r.rArBrvZ register_openr„Z register_saveZregister_extensionZ register_mimer=r=r=r>Ú<module>s$      K#G