
    &Thf-                        d dl Z d dlmZ d dlmZmZ ddlmZmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ dZd Zd Z G d d      Z G d de	j                        Z ej4                  ej6                  ee        ej8                  ej6                  e        ej:                  ej6                  d        ej<                  ej6                  d       y)    N)BytesIO)ceillog   )BmpImagePluginImage	ImageFilePngImagePlugin)i16le)i32le)o8)o16le)o32les      c           	         |j                  t               | j                  j                  d      dk(  }| j                  j                  dg d      }g }| g| j                  j                  dg       z   }| j                  \  }}t        t        |            D ]  }	|	d   |kD  s|	d   |kD  s|	d   dkD  s|	d   dkD  r%|D ]  }
|
j                  |	k7  r|j                  |
       |rt        j                  |
j                     d   }|g}|D ]Y  }|j                  |	k7  rt        j                  |j                     d   }||vs8|j                  |       |j                  |       [   
j                         }|j                  |	t        j                  j                  d 	       |j                  |         |j                  t!        t#        |                   |j%                         t#        |      d
z  z   }|D ]   }|j                  \  }}|j                  t'        |dk  r|nd             |j                  t'        |dk  r|nd             |r t        j                  |j                     dd  nd\  }}|j                  t'        |             |j                  d       |j                  d       |j                  t!        |             t)               }|rM|j+                  |d       |dk7  rHt        j,                  d	      }t/        j0                  ||dd|	z   ddfg       n|j+                  |d       |j3                  d       |j5                         }|r|d d t7        |dz        z   |dd  z   }t#        |      }|j                  t7        |             |j                  t7        |             |j%                         }|j3                  |       |j                  |       ||z   }|j3                  |        y )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                         Z/home/stella.sw7ft.com/public_html/venv/lib/python3.12/site-packages/PIL/IcoImagePlugin.pyr:   r:   *   s}   HHV
..

_
-
6CNNRE F4"..,,_bAALGGME6s5z" !7U?d1g.$q'C-47S=' 	!K4'MM+&%**;+;+;<Q?!F	 , /H}}, )..x}}=a@D9, h/!((./ !	!&  $$&EOOD%"2"2":":ONMM% 3!4 HHSVWWYVr))F "

v
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                     | d d t         k(  S )N   )r(   )prefixs    rQ   _acceptrV   u   s    "1:rR   c                   .    e Zd Zd Zd ZddZddZd Zy)IcoFilec                     |j                  d      }t        |      sd}t        |      || _        g | _        t        |d      | _        t        | j                        D ]  }|j                  d      }|d   |d   |d   |d   t        |d      t        |d      t        |d	      t        |d
      d}dD ]  }||   r	d||<    |d   xs& |d   dk7  xr t        t        |d   d            xs d|d<   |d   |d   f|d<   |d   |d   z  |d<   | j                  j                  |        t        | j                  d       | _        t        | j                  d       | _        | j                  j                          y)zL
        Parse image from file-like object containing ico file data
           znot an ICO filerT   r   r   r   r%      r$   r&   )rC   rD   nb_colorreservedplanesbppr+   rJ   )rC   rD   r   r_   r\   color_depthrC   rD   dimsquarec                     | d   S )Nr`    xs    rQ   <lambda>z"IcoFile.__init__.<locals>.<lambda>   s    a6F rR   )keyc                     | d   S )Nrb   rd   re   s    rQ   rg   z"IcoFile.__init__.<locals>.<lambda>   s
    ak rR   N)r<   rV   SyntaxErrorbufentryi16nb_itemsrangei32r   r   r.   r,   reverse)selfrk   smsgiicon_headerjs          rQ   __init__zIcoFile.__init__z   s    HHQKqz#Cc""
 Aq	 t}}% !	+AA 1A$aDaDa)1ayAq	a*	K ) )"1~%(KN) E" 
+q0 >SZ!8!<=
  & #.g"6H8M!NK$/$8;x;P$PK!JJk*C!	+F DJJ,FG
 DJJ,AB


rR   c                 P    | j                   D ch c]  }|d   |d   f c}S c c}w )zJ
        Get a list of all available icon sizes and color depths.
        rC   rD   )rl   )rr   hs     rQ   r   zIcoFile.sizes   s)     48::>a7Qx[)>>>s   #c                 p    t        | j                        D ]  \  }}||d   k(  s|du s	||d   k(  s|c S  y)Nra   Fr`   r   )	enumeraterl   )rr   r+   r_   ru   rz   s        rQ   getentryindexzIcoFile.getentryindex   sF    djj) 	DAqqxSE\SAm<L5L	 rR   c                 D    | j                  | j                  ||            S )z,
        Get an image from the icon
        )rI   r}   )rr   r+   r_   s      rQ   getimagezIcoFile.getimage   s      zz$,,T3788rR   c                    | j                   |   }| j                  j                  |d          | j                  j                  d      }| j                  j                  |d          |dd t        j
                  k(  r@t	        j                  | j                        }t        j                  |j                         |S t        j                  | j                        }t        j                  |j                         |j                  d   t        |j                  d   dz        f|_        |j                  d   \  }}}}|d|j                  z   ||f|j                  d<   |d   }	d	|	k(  r| j                  j                  |       | j                  j                  |j                  d   |j                  d   z  d
z        ddd
   }
t        j                  d|j                  |
dd      }n|j                  d   }|d	z  dkD  r|d	|j                  d   d	z  z
  z  }t        ||j                  d   z  dz        }|d   |d   z   |z
  }| j                  j                  |       | j                  j                  |      }t        j                  d|j                  |ddt        |dz        df      }|j!                  d      }|j#                  |       |S )z-
        Get an image from frame idx
        rJ   r$   Nr   r   r%   r!   r_   r   rT   r[   Lr    )r   r   r"   r+   r   z1;Ir"   RGBA)rl   rk   r;   r<   r
   r(   PngImageFiler   _decompression_bomb_checkr+   r   DibImageFileint_sizetile
frombufferconvertputalpha)rr   idxheaderdatar>   deoar_   alpha_bytesmaskwtotal_bytesand_mask_offset	mask_datas                   rQ   rI   zIcoFile.frame   st   
 CfX&'xx}}QfX&'8~,,,,,TXX6B++BGG4~ 	y  ,,TXX6B++BGG4 
C
Q$78BHJAq!QFRWW,a2BGGAJ -CSy a "hhmmBGGAJ,Ca,GHAN ''GG  GGAJFa<rwwqzB//A
 "1rwwqz>Q"67"("2VF^"Ck"Qo. HHMM+6	 ''GGCAJ+ F#BKK	rR   N)F)__name__
__module____qualname__rx   r   r}   r   rI   rd   rR   rQ   rX   rX   y   s    9v?9MrR   rX   c                   ^    e Zd ZdZdZdZd Zed        Zej                  d        Zd Z
d Zy	)
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
    ICOzWindows Iconc                     t        | j                        | _        | j                  j                         | j                  d<   | j                  j
                  d   d   | _        | j                          y )Nr   r   ra   )rX   r?   icor   inforl   r+   loadrr   s    rQ   _openzIcoImageFile._open3  sM    477#!XX^^-		'HHNN1%e,			rR   c                     | j                   S N)r   r   s    rQ   r+   zIcoImageFile.size9  s    zzrR   c                 N    || j                   d   vrd}t        |      || _        y )Nr   z2This is not one of the allowed sizes of this image)r   
ValueErrorr   )rr   valuert   s      rQ   r+   zIcoImageFile.size=  s)    		'**FCS/!
rR   c                    | j                   B| j                   j                  | j                  k(  rt        j                  j                  |       S | j                  j                  | j                        }|j                          |j                   | _         d | _        |j                  | _        |j                  | j                  k7  rt        j                  d       | j                  j                  | j                        }t        | j                  d         }|j                  ||<   t        |      | j                  d<   |j                  | _        y y )NzImage was not the expected sizer   )r>   r+   r   r   r   r   pyaccessr0   warningswarnr}   listr   r-   )rr   r>   indexr   s       rQ   r   zIcoImageFile.loadD  s    77477<<499#<;;##D))XXtyy)
	%%GG	77diiMM;<HH**4995E7+,E77E%L!$UDIIgDI  rR   c                      y r   rd   r   s    rQ   	load_seekzIcoImageFile.load_seekX  s     	rR   N)r   r   r   __doc__formatformat_descriptionr   propertyr+   setterr   r   rd   rR   rQ   r   r     sO    ( F'   
[[  (rR   r   z.icozimage/x-icon)r   ior   mathr   r    r   r   r	   r
   _binaryr   rm   r   rp   r   r   r5   r   r=   r(   r:   rV   rX   r   register_openr   register_saveregister_extensionregister_mimerd   rR   rQ   <module>r      s   2    > > ! !  ! !
 
HV [ [D@9&& @N   L''w ?   L'' /   ,,f 5   L'' 8rR   