
    (ph.                       S SK Jr  S SKrS SKJr  S SKJrJr  S SKJ	r	  SSK
JrJrJrJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SrSS jrSS jr " S S5      r " S S\R                  5      r\R<                  " \R>                  \\5        \R@                  " \R>                  \5        \RB                  " \R>                  S5        \RD                  " \R>                  S5        g)    )annotationsN)BytesIO)ceillog)IO   )BmpImagePluginImage	ImageFilePngImagePlugin)i16le)i32le)o8)o16le)o32les      c           	     P   UR                  [        5        U R                  R                  S5      S:H  nU R                  R                  S/ SQ5      n/ nU /U R                  R                  S/ 5      -   nU R                  u  px[        [        U5      5       GH/  n	U	S   U:  d  U	S   U:  d  U	S   S:  d	  U	S   S:  a  M*  U H  n
U
R                  U	:w  a  M  UR                  U
5        U(       a  [        R                  U
R                     S   nU/nU H^  nUR                  U	:w  a  M  [        R                  UR                     S   nX;  d  M<  UR                  U5        UR                  U5        M`       M     W
R                  5       nUR                  U	[        R                  R                  S S	9  UR                  U5        GM2     UR                  [!        [#        U5      5      5        UR%                  5       [#        U5      S
-  -   nU GH  nUR                  u  pxUR                  ['        US:  a  UOS5      5        UR                  ['        US:  a  UOS5      5        U(       a   [        R                  UR                     SS  OSu  nnUR                  ['        U5      5        UR                  S5        UR                  S5        UR                  [!        U5      5        [)        5       nU(       aP  UR+                  US5        US:w  a7  [        R,                  " SW	5      n[.        R0                  " UUSSU	-   SS4/5        OUR+                  US5        UR3                  S5        UR5                  5       nU(       a  US S [7        US-  5      -   USS  -   n[#        U5      nUR                  [7        U5      5        UR                  [7        U5      5        UR%                  5       nUR3                  U5        UR                  U5        UU-   nUR3                  U5        GM     g )Nbitmap_formatbmpsizes))   r   )   r   )    r   )0   r   )@   r   )   r   )   r   append_imagesr   r   r   )reducing_gapr   )r   r       s     dibr   1rawr   r   )r!   r   png         )write_MAGICencoderinfogetsizesortedsetappendr	   SAVEmodecopy	thumbnailr
   
ResamplingLANCZOSo16lentellr   r   savenewr   _saveseekreado32)imfpfilenamer   r   framesprovided_imswidthheightr-   provided_imbits	bits_usedother_imframeoffsetcolorsimage_ioand_maskimage_bytes	bytes_lencurrents                         E/var/www/html/venv/lib/python3.13/site-packages/PIL/IcoImagePlugin.pyr<   r<   +   sd   HHV
..

_
-
6CNNRE F4"..,,_bAALGGMEs5z"7U?d1g.$q'C-47S='K4'MM+&%**;+;+;<Q?!F	 ,H}}, )..x}}=a@D, h/!((. !- ! (&  $$&EOOD%"2"2":":ONMM% 3 #4 HHSVWWYVr))F


US[Ea01
fslF23>A~**5::6qr:wf
F


T9JJx'rz 99S$/h%$<)P(Q JJx'ammo%bq/C
O;k"#>NNK$	
Y 
V'')

)#
E     c                    U S S [         :H  $ )N   )r*   )prefixs    rS   _acceptrX   v   s    "1:rT   c                  >    \ rS rSrS rS rS	S jrS	S jrS
S jrSr	g)IcoFilez   c                   UR                  S5      n[        U5      (       d  Sn[        U5      eXl        / U l        [        US5      U l        [        U R                  5       H  nUR                  S5      nUS   US   US   US   [        US5      [        US5      [        US	5      [        US
5      S.nS H  nXV   (       a  M  SXV'   M     US   =(       d0    US   S:g  =(       a    [        [        US   S5      5      =(       d    SUS'   US   US   4US'   US   US   -  US'   U R                  R                  U5        M     [        U R                  S S9U l        [        U R                  S SS9U l        g)z<
Parse image from file-like object containing ico file data
   znot an ICO filerV   r   r   r   r'      r&   r(   )rE   rF   nb_colorreservedplanesbppr-   rL   )rE   rF   r   rb   r_   color_depthrE   rF   dimsquarec                    U S   $ )Nrc    xs    rS   <lambda>"IcoFile.__init__.<locals>.<lambda>   s	    a6FrT   )keyc                    U S   $ )Nre   rg   rh   s    rS   rj   rk      s    akrT   T)rl   reverseN)r>   rX   SyntaxErrorbufentryi16nb_itemsrangei32r   r   r0   r.   )selfrp   smsgiicon_headerjs          rS   __init__IcoFile.__init__{   s    HHQKqzz#Cc""
 Aq	 t}}%AA 1A$aDaDa)1ayAq	a*	K )"~~%(KN ) E" 
+q0 >SZ!8!<=
  & #.g"6H8M!NK$/$8;x;P$PK!JJk*C &F DJJ,FG
DJJ,A4P
rT   c                T    U R                    Vs1 s H  oS   US   4iM     sn$ s  snf )z:
Get a list of all available icon sizes and color depths.
rE   rF   )rq   )rv   hs     rS   r   IcoFile.sizes   s+     48::>:a7Qx[):>>>s   %c                v    [        U R                  5       H   u  p4XS   :X  d  M  USL d
  X$S   :X  d  M  Us  $    g)Nrd   Frc   r   )	enumeraterq   )rv   r-   rb   ry   r   s        rS   getentryindexIcoFile.getentryindex   s;    djj)DAxSE\Sm<L5L * rT   c                B    U R                  U R                  X5      5      $ )z
Get an image from the icon
)rK   r   )rv   r-   rb   s      rS   getimageIcoFile.getimage   s     zz$,,T788rT   c                   U R                   U   nU R                  R                  US   5        U R                  R                  S5      nU R                  R                  US   5        USS [        R
                  :X  aB  [        R                  " U R                  5      n[        R                  " UR                  5        U$ [        R                  " U R                  5      n[        R                  " UR                  5        UR                  S   [        UR                  S   S-  5      4Ul        UR                  S   u  pVpxUSUR                  -   Xx4UR                  S'   US   n	S	U	:X  a  U R                  R                  U5        U R                  R                  UR                  S   UR                  S   -  S
-  5      SSS
2   n
[        R                  " SUR                  U
SS5      nOUR                  S   nUS	-  S:  a  US	UR                  S   S	-  -
  -  n[        XR                  S   -  S-  5      nUS   US   -   U-
  nU R                  R                  U5        U R                  R                  U5      n[        R                  " SUR                  USS[        US-  5      S45      nUR!                  S5      nUR#                  U5        U$ )z
Get an image from frame idx
rL   r&   Nr   r   r'   r#   rb   r   rV   r^   Lr"   )r   r   r$   r-   r!   z1;Ir$   RGBA)rq   rp   r=   r>   r   r*   PngImageFiler
   _decompression_bomb_checkr-   r	   DibImageFileint_sizetile
frombufferconvertputalpha)rv   idxheaderdatar@   deoarb   alpha_bytesmaskwtotal_bytesand_mask_offset	mask_datas                   rS   rK   IcoFile.frame   sn   
 CfX&'xx}}QfX&' 8~,,,,,TXX6B++BGG4~ 	y  ,,TXX6B++BGG4 
C
Q$78BHJA!FRWW,a2BGGAJ -CSy a "hhmmBGGAJ,Ca,GHAN ''GG  GGAJFa<rwwqzB//A
 "1wwqz>Q"67"("2VF^"Ck"Qo. HHMM+6	 ''GGCAJ+ F#BKK	rT   )rp   rq   rs   N)F)r   r   returnImage.Image)
__name__
__module____qualname____firstlineno__r|   r   r   r   rK   __static_attributes__rg   rT   rS   rZ   rZ   z   s    7Qr?9NrT   rZ   c                  n    \ rS rSrSrSrSrSS jr\S 5       r	\	R                  S 5       r	S rSS	 jrS
rg)IcoImageFilei  a  
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
ICOzWindows Iconc                    [        U R                  5      U l        U R                  R                  5       U R                  S'   U R                  R
                  S   S   U l        U R                  5         g )Nr   r   rd   )rZ   rA   icor   inforq   r-   loadrv   s    rS   _openIcoImageFile._open3  sM    477#!XX^^-		'HHNN1%e,			rT   c                    U R                   $ N)r   r   s    rS   r-   IcoImageFile.size9  s    zzrT   c                N    XR                   S   ;  a  Sn[        U5      eXl        g )Nr   z2This is not one of the allowed sizes of this image)r   
ValueErrorr   )rv   valuerx   s      rS   r-   r   =  s%    		'**FCS/!
rT   c                   U R                   bC  U R                   R                  U R                  :X  a  [        R                  R                  U 5      $ U R                  R                  U R                  5      nUR                  5         UR                   U l         S U l        UR                  U l        UR                  (       a  UR                  U l	        UR                  U R                  :w  a  [        R                  " S5        U R                  R                  U R                  5      n[        U R                  S   5      nUR                  X2'   [        U5      U R                  S'   UR                  U l        g g )NzImage was not the expected sizer   )r@   r-   r
   r   r   r   pyaccessr2   _modepalettewarningswarnr   listr   r/   )rv   r@   indexr   s       rS   r   IcoImageFile.loadD  s    77477<<499#<;;##D))XXtyy)
	%%WW
::::DL77diiMM;<HH**4995E7+,E77EL!$UDIIgDI  rT   c                    g r   rg   )rv   poss     rS   	load_seekIcoImageFile.load_seekZ  s     	rT   )r   r   r   r@   r   r   r-   N)r   None)r   r   r   r   )r   r   r   r   __doc__formatformat_descriptionr   propertyr-   setterr   r   r   rg   rT   rS   r   r     sO    ( F'   
[[  ,rT   r   z.icozimage/x-icon)r@   r   rA   z	IO[bytes]rB   zstr | bytesr   r   )rW   bytesr   bool)#
__future__r   r   ior   mathr   r   typingr    r	   r
   r   r   _binaryr   rr   r   ru   r   r   r7   r   r?   r*   r<   rX   rZ   r   register_openr   register_saveregister_extensionregister_mimerg   rT   rS   <module>r      s   . #     > > ! !  ! !
 
HV Z ZBB9&& BR   L''w ?   L'' /   ,,f 5   L'' 8rT   