CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
IcoImagePlugin.cpython-310.pyc121 linesDownload Raw Back to __pycache__
1o

2��Yi�4�@sddlmZddlZddlmZddlmZmZddlm	Z	m3Z4ddlmZm
Z
mZmZddlmZdd	lmZdd5lmZddlmZddlmZd
Zd%dd�Zd&dd�ZGdd�de6�ZGdd �d �ZGd!d"�d"ej�Ze
� ej!ee�e
�"ej!e�e
�#ej!d#�e
�$ej!d$�dS)'�)�annotationsN)�BytesIO)�ceil�log)�IO�7NamedTuple�)�BmpImagePlugin�Image�	ImageFile�PngImagePlugin)�i16le)�i32le)�o8)�o16le)�o32les�im�Image.Image�fp�	IO[bytes]�filename�str | bytes�return�NonecCs�|�t�|j�d�dk}|j�dgd��}g}|g|j�dg�}|j\}}tt|��D]m}	|	d|ksG|	d|ksG|	ddksG|	ddkrHq-|D]<}8|9j|	krRqJ|�|10�|r�tj	|11j12d}|g}|D]}
|
j|	krnqftj	|
j13d}||vr�|�|
�|�|�qfn|14��}|j|	t
jjdd	�|�|�q-|�tt|���|��t|�d15}|D]�}|j\}}|�t|dkr�|nd��|�t|dkr�|nd��|r�tj	|j16dd�nd\}}|�t|��|�d�|�d
�|�t|��t�}|�r!|�|d�|dk�r t
�d|	�}t�||t�dd|	dd�g�n|�|d�|�d�|��}|�rE|dd�t|d�|dd�}t|�}|�t|��|�t|��|��}|�|�|�|�||}|�|�q�dS)NZ
bitmap_format�bmp�sizes))�r)�r)� r)�0r)�@r )�r!)�r"Z
append_imagesrrr")Zreducing_gapr)rr�sZdibr�1�raw�rr)r$r�����Zpng���)�write�_MAGICZencoderinfo�get�size�sorted�set�appendr	ZSAVE�mode�copyZ	thumbnailr17Z18ResamplingZLANCZOS�o16�len�tellrr�save�newr�_save�_Tile�seek�read�o32)rrrrr�framesZprovided_ims�width�heightr.Zprovided_im�bitsZ	bits_usedZother_im�frame�offset�colorsZimage_ioZand_maskZimage_bytesZ	bytes_len�current�rF�|E:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\PIL/IcoImagePlugin.pyr99s�19�2002122232425�26�27 282930��31$3233�r9�prefix�bytes�boolcCs34|�t�S�N)�35startswithr,)rHrFrFrG�_accept�s36rMc@sfeZdZUded<ded<ded<ded<ded<ded<ded<ded	<d37ed<ded<ded
<dS)�38IconHeader�intr?r@�nb_color�reserved�planes�bppr.rC�tuple[int, int]�dim�square�color_depthN)�__name__�39__module__�__qualname__�__annotations__rFrFrFrGrN�s40rNc@sBeZdZddd�Zddd	�Zdddd�Zdddd�Zddd�ZdS)�IcoFile�bufrrrc41Cs|�d�}t|�sd}t|��||_g|_t|d�|_t|j�D]P}|�d�}|dp,d}|dp2d}|d}t|d�}t||||d	t|d�t|d�t	|d42�t	|d�||f|||pg|dkrft43t|d��pgdd�}	|j�|	�q t
|jd
d�d�|_t
|jdd�dd�|_dS)zL44        Parse image from file-like object containing ico file data45        �znot an ICO file�rrr"rr)�r(r*)r?r@rPrQrRrSr.rCrUrVrWcS�|jSrK)rW��xrFrFrG�<lambda>��z"IcoFile.__init__.<locals>.<lambda>)�keycSrarK)rVrbrFrFrGrd�reT)rf�reverseN)r<rM�SyntaxErrorr]�entry�i16Znb_items�rangerN�i32rrr1r/)46�selfr]�s�msg�ir?r@rPrSZicon_headerrFrFrG�__init__�s:474849�zIcoFile.__init__�set[tuple[int, int]]cCsdd�|jD�S)zI50        Get a set of all available icon sizes and color depths.51        cSsh|]}|j|jf�qSrF)r?r@)�.0�hrFrFrG�	<setcomp>�sz IcoFile.sizes.<locals>.<setcomp>)ri�rmrFrFrGr�sz
IcoFile.sizesFr.rTrS�52int | boolrOcCs<t|j�D]\}}||jkr|dus||jkr|SqdS)NFr)�	enumeraterirUrW)rmr.rSrprtrFrFrG�
getentryindex�s53�zIcoFile.getentryindexrcCs|�|�||��S)z,54        Get an image from the icon55        )rBry)rmr.rSrFrFrG�getimage�szIcoFile.getimage�idxc56Cs|j|}|j�|j�|j�d�}|j�|j�|dd�tjkr0t�|j�}t�	|j57�|St�|j�}t�	|j58�|j59dt
|j60dd�f|_|jd\}}}}t�|d|j61||�|jd<|jdkr�|j�|�|j�|j62d|j63dd�d	dd�}	zt�d64|j65|	dd�}66Wnity�tjr�d}67n�YnZw|j68d}|ddkr�|d|j69dd7}t
||j70dd�}|j|j71|}
|j�|
�|j�|�}zt�d
|j72|ddt
|d�df�}73Wnty�tjr�d}74n�Ynw|75�r|�d�}|�|76�|S)z-77        Get an image from frame idx78        r(Nrrr)r&rr_r`�Lr%)r|rr'r$z1;Ir'ZRGBA)rir]r;rCr<rr,ZPngImageFiler79Z_decompression_bomb_checkr.r	ZDibImageFilerO�_sizeZtilerr:rSZ80frombuffer�81ValueErrorZLOAD_TRUNCATED_IMAGES�convertZputalpha)rmr{�header�datar�d�e�o�aZalpha_bytes�mask�w�total_bytesZand_mask_offsetZ	mask_datarFrFrGrB�sn82K�83*���84���	8586z
IcoFile.frameN)r]rrr)rrr)F)r.rTrSrwrrO)r.rTrSrwrr)r{rOrr)rXrYrZrqrryrzrBrFrFrFrGr\�s87882r\c@sTeZdZdZdZdZddd�Zedd	d89��Zej	ddd90��Zddd�Z91ddd�ZdS)�IcoImageFilea�92    PIL read-only image support for Microsoft Windows .ico files.93 94    By default the largest resolution image in the file will be loaded. This95    can be changed by altering the 'size' attribute before calling 'load'.96 97    The info dictionary has a key 'sizes' that is a list of the sizes available98    in the icon file.99 100    Handles classic, XP and Vista icon formats.101 102    When saving, PNG compression is used. Support for this was only added in103    Windows Vista. If you are unable to view the icon in Windows, convert the104    image to "RGBA" mode before saving.105 106    This plugin is a refactored version of Win32IconImagePlugin by Bryan Davis107    <casadebender@gmail.com>.108    https://code.google.com/archive/p/casadebender/wikis/Win32IconImagePlugin.wiki109    ZICOzWindows IconrrcCsF|jdusJ�t|j�|_|j��|jd<|jjdj|_|��dS)Nrr)	rr\�icor�inforirUr.�loadrvrFrFrG�_openVs110zIcoImageFile._openrTcCrarK)r}rvrFrFrGr.]szIcoImageFile.size�valuecCs$||jdvr
d}t|��||_dS)Nrz2This is not one of the allowed sizes of this image)r�r~r})rmr�rorFrFrGr.as111�Image.core.PixelAccess | NonecCs�|jdur|jj|jkrtj�|�S|j�|j�}|��|j|_|j|_|j	r,|j	|_	|j|jkrUt112�d�|j�|j�}t
|jd�}|j||<t|�|jd<|j|_tj�|�S)NzImage was not the expected sizer)Z_imrr.r113r�r�rzr2�_mode�palette�warnings�warnry�listr�r0)rmr�indexrrFrFrGr�hs 114115zIcoImageFile.load�posrOcCsdSrKrF)rmr�rFrFrG�	load_seek~szIcoImageFile.load_seekN)rr)rrT)r�rTrr)rr�)r�rOrr)rXrYrZ�__doc__�format�format_descriptionr��propertyr.�setterr�r�rFrFrFrGr�>s116117r�z.icozimage/x-icon)rrrrrrrr)rHrIrrJ)%�118__future__rr��ior�mathrr�typingrr�r	r119rr�_binaryr
rjrrlrrr4rr=r,r9rMrNr\r�Z
register_openr�Z
register_saveZregister_extensionZ
register_mimerFrFrFrG�<module>s,$120121M'J
Aluode/PerceptionLabPortable · CoolFace