
    Rf6-                       d dl mZ 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
j        ej        ee            e
j        ej        e            e
j        ej        d            e
j         ej        d           dS )    )annotationsN)BytesIO)ceillog   )BmpImagePluginImage	ImageFilePngImagePlugin)i16le)i32le)o8)o16le)o32les      c           	     	   |                     t                     | j                            d          dk    }| j                            dg d          }g }| g| j                            dg           z   }| j        \  }}t          t          |                    D ])}	|	d         |k    s$|	d         |k    s|	d         dk    s|	d         dk    r4|D ]}
|
j        |	k    r|                    |
           |r|t          j	        |
j
                 d         }|g}|D ]Y}|j        |	k    rt          j	        |j
                 d         }||vr*|                    |           |                    |           Z nP|
                                }|                    |	t          j        j        d 	           |                    |           +|                     t!          t#          |                               |                                t#          |          d
z  z   }|D ]i}|j        \  }}|                     t'          |dk     r|nd                     |                     t'          |dk     r|nd                     |rt          j	        |j
                 dd          nd\  }}|                     t'          |                     |                     d           |                     d           |                     t!          |                     t)                      }|rP|                    |d           |dk    r3t          j        d|	          }t/          j        ||dd|	z   ddfg           n|                    |d           |                    d           |                                }|r(|d d         t7          |dz            z   |dd          z   }t#          |          }|                     t7          |                     |                     t7          |                     |                                }|                    |           |                     |           ||z   }|                    |           kd S )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                         D/var/www/html/env/lib/python3.11/site-packages/PIL/IcoImagePlugin.pyr;   r;   *   s\   HHV
.

_
-
-
6CNRRR E F4".,,_bAAALGME6s5zz"" ! !7U??d1g..$q'C--47S==' 	! 	!K4''MM+&&& /%*;+;<Q?!F	 , / /H},, ).x}=a@D9,, h///!((...E  $$&&EOOD%"2":ONNNMM%   HHSVWWYYVr))F " "
v
US[[EEa00111
fsllFF22333>AN~*5:6qrr::wf
F


T99 		(JJx'''rzz 9S$//h%$<)P(Q   JJx'''ammoo 	O%bqb/C
OO;k"##>NNK$$	
Y   
V''))

)#
E" "    c                (    | d d         t           k    S )N   )r)   )prefixs    rR   _acceptrW   u   s    "1":rS   c                  0    e Zd Zd Zd ZddZddZd ZdS )	IcoFilec                X   |                     d          }t          |          sd}t          |          || _        g | _        t          |d          | _        t          | j                  D ]}|                     d          }|d         |d         |d         |d         t          |d          t          |d          t          |d	          t          |d
          d}dD ]}||         sd||<   |d         p0|d         dk    o"t          t          |d         d                    pd|d<   |d         |d         f|d<   |d         |d         z  |d<   | j                            |           t          | j        d           | _        t          | j        d d          | _        dS )zL
        Parse image from file-like object containing ico file data
           znot an ICO filerU   r   r   r   r&      r%   r'   )rD   rE   nb_colorreservedplanesbppr,   rK   rD   rE   r   r`   r]   color_depthrD   rE   dimsquarec                    | d         S )Nrb    xs    rR   <lambda>z"IcoFile.__init__.<locals>.<lambda>   s    a6F rS   )keyc                    | d         S )Nrd   rf   rg   s    rR   ri   z"IcoFile.__init__.<locals>.<lambda>   s
    ak rS   T)rj   reverseN)r=   rW   SyntaxErrorbufentryi16nb_itemsrangei32r   r   r/   r-   )selfrn   smsgiicon_headerjs          rR   __init__zIcoFile.__init__z   s    HHQKKqzz 	##Cc"""
 Aq		 t}%% !	+ !	+AA 1A$aDaDa))1ayyAq		a**	 	K ) ) )"1~ )%(KN
 E" 
+q0 >SZ!8!<<==
  & #.g"6H8M!NK$/$8;x;P$PK!Jk****DJ,F,FGGG
DJ,A,A4PPP


rS   c                $    d | j         D             S )zJ
        Get a list of all available icon sizes and color depths.
        c                .    h | ]}|d          |d         fS ra   rf   ).0hs     rR   	<setcomp>z IcoFile.sizes.<locals>.<setcomp>   s%    >>>a7Qx[)>>>rS   )ro   rt   s    rR   r   zIcoFile.sizes   s     ?>4:>>>>rS   Fc                z    t          | j                  D ]%\  }}||d         k    r|du s||d         k    r|c S &dS )Nrc   Frb   r   )	enumeratero   )rt   r,   r`   rw   r~   s        rR   getentryindexzIcoFile.getentryindex   sT    dj)) 	 	DAqqxSE\\SAm<L5L5LqrS   c                T    |                      |                     ||                    S )z,
        Get an image from the icon
        )rJ   r   )rt   r,   r`   s      rR   getimagezIcoFile.getimage   s&     zz$,,T377888rS   c                d   | j         |         }| j                            |d                    | j                            d          }| j                            |d                    |dd         t          j        k    r4t	          j        | j                  }t          j        |j	                   nt          j        | j                  }t          j        |j	                   |j	        d         t          |j	        d         dz            f|_        |j        d         \  }}}}|d|j	        z   ||f|j        d<   |d         }	d	|	k    rw| j                            |           | j                            |j	        d         |j	        d         z  d
z            ddd
         }
t          j        d|j	        |
dd          }n|j	        d         }|d	z  dk    r|d	|j	        d         d	z  z
  z  }t          ||j	        d         z  dz            }|d         |d         z   |z
  }| j                            |           | j                            |          }t          j        d|j	        |ddt          |dz            df          }|                    d          }|                    |           |S )z-
        Get an image from frame idx
        rK   r%   Nr   r   r&   r"   r`   r   rU   r\   Lr!   )r   r   r#   r,   r    z1;Ir#   RGBA)ro   rn   r<   r=   r   r)   PngImageFiler	   _decompression_bomb_checkr,   r   DibImageFileint_sizetile
frombufferconvertputalpha)rt   idxheaderdatar?   deoar`   alpha_bytesmaskwtotal_bytesand_mask_offset	mask_datas                   rR   rJ   zIcoFile.frame   s   
 CfX&'''x}}QfX&'''8~,,,,TX66B+BG4444  ,TX66B+BG444 
C
Q$7$78BHJAq!QFRW,a2BGAJ -CSyy a   "hmmBGAJ,Ca,GHHAN 'G   GAJFa<<rwqzB//A
 "1rwqz>Q"677"("2VF^"Ck"Qo... HMM+66	 'GCAJJ+  F##BKK	rS   N)F)__name__
__module____qualname__rz   r   r   r   rJ   rf   rS   rR   rY   rY   y   sr        7Q 7Q 7Qr? ? ?   9 9 9 9M M M M MrS   rY   c                  b    e Zd ZdZdZdZd Zed             Zej	        d             Zd Z
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
    ICOzWindows Iconc                    t          | j                  | _        | j                                        | j        d<   | j        j        d         d         | _        |                                  d S )Nr   r   rc   )rY   r@   icor   inforo   r,   loadr   s    rR   _openzIcoImageFile._open1  sQ    47##!X^^--	'HN1%e,			rS   c                    | j         S N)r   r   s    rR   r,   zIcoImageFile.size7  s
    zrS   c                T    || j         d         vrd}t          |          || _        d S )Nr   z2This is not one of the allowed sizes of this image)r   
ValueErrorr   )rt   valuerv   s      rR   r,   zIcoImageFile.size;  s0    	'***FCS//!


rS   c                8   | j         4| j         j        | j        k    rt          j                            |           S | j                            | j                  }|                                 |j         | _         d | _        |j        | _        |j        | j        k    r|t          j
        d           | j                            | j                  }t          | j        d                   }|j        ||<   t          |          | j        d<   |j        | _        d S d S )NzImage was not the expected sizer   )r?   r,   r	   r   r   r   pyaccessr1   _modewarningswarnr   listr   r.   )rt   r?   indexr   s       rR   r   zIcoImageFile.loadB  s    747<49#<#<;##D)))Xty))
			%W
7diM;<<<H**4955E7+,,E7E%L!$UDIgDIII  rS   c                    d S r   rf   r   s    rR   	load_seekzIcoImageFile.load_seekV  s	     	rS   N)r   r   r   __doc__formatformat_descriptionr   propertyr,   setterr   r   rf   rS   rR   r   r     s         ( F'     X 
[  [     (    rS   r   z.icozimage/x-icon)!
__future__r   r   ior   mathr   r    r   r	   r
   r   _binaryr   rp   r   rs   r   r   r6   r   r>   r)   r;   rW   rY   r   register_openr   register_saveregister_extensionregister_mimerf   rS   rR   <module>r      s  . # " " " " "                > > > > > > > > > > > > ! ! ! ! ! ! ! ! ! ! ! !       ! ! ! ! ! ! ! ! ! ! ! !
 
H H HV     Y Y Y Y Y Y Y Y@@ @ @ @ @9& @ @ @N  L'w ? ? ?  L' / / /  ,f 5 5 5  L' 8 8 8 8 8rS   