
    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j        ej        ee            ej        ej        e            ej        ej        d            ej        ej        d           dS )    N)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                         f/var/www/html/mycamper/aliexpress-site/backend/venv/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    rQ   _acceptrV   u   s    "1":rR   c                   0    e Zd Zd Zd ZddZddZd ZdS )	IcoFilec                    |                     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           | _        | j                                         dS )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 )Nra    xs    rQ   <lambda>z"IcoFile.__init__.<locals>.<lambda>   s    a6F rR   )keyc                     | d         S )Nrc   re   rf   s    rQ   rh   z"IcoFile.__init__.<locals>.<lambda>   s
    ak rR   N)r<   rV   SyntaxErrorbufentryi16nb_itemsrangei32r   r   r.   r,   reverse)selfrl   smsgiicon_headerjs          rQ   __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,ABBB

rR   c                 $    d | j         D             S )zJ
        Get a list of all available icon sizes and color depths.
        c                 .    h | ]}|d          |d         fS r`   re   ).0hs     rQ   	<setcomp>z IcoFile.sizes.<locals>.<setcomp>   s%    >>>a7Qx[)>>>rR   )rm   rs   s    rQ   r   zIcoFile.sizes   s     ?>4:>>>>rR   Fc                 z    t          | j                  D ]%\  }}||d         k    r|du s||d         k    r|c S &dS )Nrb   Fra   r   )	enumeraterm   )rs   r+   r_   rv   r}   s        rQ   getentryindexzIcoFile.getentryindex   sT    dj)) 	 	DAqqxSE\\SAm<L5L5LqrR   c                 T    |                      |                     ||                    S )z,
        Get an image from the icon
        )rI   r   )rs   r+   r_   s      rQ   getimagezIcoFile.getimage   s&     zz$,,T377888rR   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
        rJ   r$   Nr   r   r%   r!   r_   r   rT   r[   Lr    )r   r   r"   r+   r   z1;Ir"   RGBA)rm   rl   r;   r<   r
   r(   PngImageFiler   _decompression_bomb_checkr+   r   DibImageFileint_sizetile
frombufferconvertputalpha)rs   idxheaderdatar>   deoar_   alpha_bytesmaskwtotal_bytesand_mask_offset	mask_datas                   rQ   rI   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	rR   N)F)__name__
__module____qualname__ry   r   r   r   rI   re   rR   rQ   rX   rX   y   so        9 9 9v? ? ?   9 9 9 9M M M M MrR   rX   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   rb   )rX   r?   icor   inform   r+   loadr   s    rQ   _openzIcoImageFile._open3  sQ    47##!X^^--	'HN1%e,			rR   c                     | j         S N)r   r   s    rQ   r+   zIcoImageFile.size9  s
    zrR   c                 T    || j         d         vrd}t          |          || _        d S )Nr   z2This is not one of the allowed sizes of this image)r   
ValueErrorr   )rs   valueru   s      rQ   r+   zIcoImageFile.size=  s0    	'***FCS//!


rR   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   pyaccessr0   warningswarnr   listr   r-   )rs   r>   indexr   s       rQ   r   zIcoImageFile.loadD  s    747<49#<#<;##D)))Xty))
			%G	7diM;<<<H**4955E7+,,E7E%L!$UDIgDIII  rR   c                     d S r   re   r   s    rQ   	load_seekzIcoImageFile.load_seekX  s	     	rR   N)r   r   r   __doc__formatformat_descriptionr   propertyr+   setterr   r   re   rR   rQ   r   r     s         ( F'     X 
[  [     (    rR   r   z.icozimage/x-icon)r   ior   mathr   r    r   r   r	   r
   _binaryr   rn   r   rq   r   r   r5   r   r=   r(   r:   rV   rX   r   register_openr   register_saveregister_extensionregister_mimere   rR   rQ   <module>r      s  2                > > > > > > > > > > > > ! ! ! ! ! ! ! ! ! ! ! !       ! ! ! ! ! ! ! ! ! ! ! !
 
H H HV     [ [ [ [ [ [ [ [D@ @ @ @ @9& @ @ @N  L'w ? ? ?  L' / / /  ,f 5 5 5  L' 8 8 8 8 8rR   