3
V^9	  ã               @   sH   d dl mZmZmZ d dlmZmZmZ	 G dd„ dejƒZ
d	dd„ZdS )
é   )Ú	ImageFileÚImagePaletteÚUnidentifiedImageError)Úi8Úi16beÚi32bec               @   s   e Zd ZdZdZdd„ ZdS )ÚGdImageFileZGDzGD uncompressed imagesc             C   sæ   | j jdƒ}t|d d… ƒdkr(tdƒ‚d| _t|dd… ƒt|dd… ƒf| _t|d ƒ}|rddnd	}t|d
| d
| d … ƒ}|dk r–|| jd< t	j
d|d
| d d
| d d … ƒ| _dd| j d
| d d dfg| _d S )Ni  é   éþÿ  éÿÿ  zNot a valid GD 2.x .gd fileÚLé   é   é    é   é   ZtransparencyZXBGRÚrawr   )r
   r   i   )r   r   i   )r   r   r   )ÚfpÚreadÚi16ÚSyntaxErrorÚmodeÚ_sizer   Úi32Úinfor   r   ZpaletteÚsizeZtile)ÚselfÚsZ	trueColorZtrueColorOffsetZtindex© r   ú1/tmp/pip-build-zn8x4q5s/pillow/PIL/GdImageFile.pyÚ_open)   s    "
&zGdImageFile._openN)Ú__name__Ú
__module__Ú__qualname__ÚformatÚformat_descriptionr    r   r   r   r   r   $   s   r   Úrc             C   s:   |dkrt dƒ‚yt| ƒS  tk
r4   tdƒ‚Y nX dS )a)  
    Load texture from a GD image file.

    :param filename: GD file name, or an opened file handle.
    :param mode: Optional mode.  In this version, if the mode argument
        is given, it must be "r".
    :returns: An image instance.
    :raises IOError: If the image could not be read.
    r&   zbad modezcannot identify this image fileN)Ú
ValueErrorr   r   r   )r   r   r   r   r   ÚopenE   s    
r(   N)r&   )Ú r   r   r   Ú_binaryr   r   r   r   r   r   r(   r   r   r   r   Ú<module>   s   	!