Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/PIL/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/PIL/__pycache__/IcoImagePlugin.cpython-35.pyc



�ʴW$�@sddlZddlmZddlmZmZmZmZmZddl	m
Z
mZdZej
Z
ejZejZdZdd�Zd	d
�ZGdd�de�ZGd
d�dej�Zejejee�ejeje�ejejd�dS)�N)�BytesIO)�Image�	ImageFile�BmpImagePlugin�PngImagePlugin�_binary)�log�ceilz0.1sc
s�|jt�|jjddddddddg�}|j\��t��fd	d
�|�|jtjdt|���|j	�t|�d}xX|D]P}|\��|jtjd���|jtjd���|jd
�|jd
�|jd�|jtjdd��t
�}|j�}|j|t
j�|j|d�|jd�|j�}t|�}	|jtjd|	��|jtjd|��|j	�}
|j|�|j|�||	}|j|
�q�WdS)N�sizes��� �0�@��csH|d�ks@|d�ks@|ddks@|ddkrDdSdS)Nr�rFT�)�x)�height�widthr�E/opt/alt/python35/lib64/python3.5/site-packages/PIL/IcoImagePlugin.py�<lambda>1s z_save.<locals>.<lambda>z<H�BssZpngrz<I)rr)rr)r
r
)rr)rr)rr)rr)�write�_MAGICZencoderinfo�get�size�filter�struct�pack�len�tellr�copyZ	thumbnailrZLANCZOS�save�seek�read)�im�fp�filenamer
�offsetrZimage_io�tmpZimage_bytesZ	bytes_len�currentr)rrr�_save+s>




	



r-cCs|dd�tkS)N�)r)�prefixrrr�_acceptNsr0c@sCeZdZdd�Zdd�Zddd�Zdd	�Zd
S)�IcoFilecCs|jd�}t|�s'td��||_g|_t|dd��|_xdt|j�D]S}|jd�}dt|d�dt|d	�d
t|d�dt|d
�dt|dd��dt|dd��dt	|dd��dt	|dd��i}x"dD]}||sd||<qW|dpp|d
dkrmt
t|d
d��ppd|d<|d|df|d<|d|d|d<|jj|�qbWt
|jddd��|_t
|jddd��|_|jj�dS)zL
        Parse image from file-like object containing ico file data
        �znot an ICO filer.NrrrrrZnb_color��reserved�Zplanes�bppr�r*���color_depth�dim�square�keycSs|dS)Nr:r)rrrrr�sz"IcoFile.__init__.<locals>.<lambda>cSs|dS)Nr<r)rrrrr�s)rr)r&r0�SyntaxError�buf�entry�i16Znb_items�range�i8�i32r	r�append�sorted�reverse)�selfr?�s�iZicon_header�jrrr�__init__Ss<		



zIcoFile.__init__cCstdd�|jD��S)zJ
        Get a list of all available icon sizes and color depths.
        css#|]}|d|dfVqdS)rrNr)�.0�hrrr�	<genexpr>�sz IcoFile.sizes.<locals>.<genexpr>)�setr@)rHrrrr
�sz
IcoFile.sizesFcCsfxVt|j�D]E\}}||dkr|dksH||dkr|j|�SqW|jd�S)z,
        Get an image from the icon
        r;Fr:r)�	enumerater@�frame)rHrr6rJrNrrr�getimage�s,zIcoFile.getimagec	Cs�|j|}|jj|d�|jjd�}|jj|d�|dd�tjkrutj|j�}ntj|j�}|j	dt
|j	dd�f|_	|jd\}}}}|d|j	||f|jd<|d}	d}
x5tjj
�D]$}|	tj|dkr|}
PqWd|
kr�|jj|�|jj|j	d|j	dd�d	dd�}tjd
|j	|dd�}
n�|j	d}|ddkr�|d|j	dd7}|t
|j	d|j	d|
d�}t
||j	dd�}|jj|�|jj|�}tjd
|j	|ddt
|d�df�}
|jd�}|j|
�|S)z-
        Get an image from frame idx
        r*r7Nrrr3r
r.r5�L�rawg @�1z1;IZRGBA)rr���)rTrrWrW)r@r?r%r&rrZPngImageFilerZDibImageFiler�intZtileZBIT2MODE�keysrZ
frombuffer�convertZputalpha)rH�idx�header�datar'�d�e�o�a�moder6�kZalpha_bytes�mask�wZand_mask_offsetZtotal_bytesZmaskDatarrrrR�sT
' 
5

z
IcoFile.frameN)�__name__�
__module__�__qualname__rLr
rSrRrrrrr1Rs7	r1c@sFeZdZdZdZdZdd�Zdd�Zdd	�Zd
S)�IcoImageFilea9
    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.

    This plugin is a refactored version of Win32IconImagePlugin by Bryan Davis
    <casadebender@gmail.com>.
    https://code.google.com/archive/p/casadebender/wikis/Win32IconImagePlugin.wiki
    ZICOzWindows IconcCsMt|j�|_|jj�|jd<|jjdd|_|j�dS)Nr
rr;)r1r(�icor
�infor@r�load)rHrrr�_openszIcoImageFile._opencCsG|jj|j�}|j�|j|_|j|_|j|_dS)N)rjrSrrlr'rb)rHr'rrrrl
s

zIcoImageFile.loadcCsdS)Nr)rHrrr�	load_seekszIcoImageFile.load_seekN)	rfrgrh�__doc__�formatZformat_descriptionrmrlrnrrrrri�sriz.ico)r�iorZPILrrrrr�mathrr	�__version__rCZi16lerAZi32lerDrr-r0�objectr1riZ
register_openrpZ
register_saveZregister_extensionrrrr�<module>s(			#�(