o
     ÈPj  ã                   @  sz   d Z ddlmZ ddl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 G d	d
„ d
ejƒZdddd„ZdS )a‚  
.. note::
    This format cannot be automatically recognized, so the
    class is not registered for use with :py:func:`PIL.Image.open()`.  To open a
    gd file, use the :py:func:`PIL.GdImageFile.open()` function instead.

.. warning::
    THE GD FORMAT IS NOT DESIGNED FOR DATA INTERCHANGE.  This
    implementation is provided for convenience and demonstrational
    purposes only.
é    )Úannotations)ÚIOé   )ÚImageÚ	ImageFileÚImagePaletteÚUnidentifiedImageError)Úi16be)Úi32be)ÚStrOrBytesPathc                   @  s"   e Zd ZdZdZdZd	dd„ZdS )
ÚGdImageFilea%  
    Image plugin for the GD uncompressed format.  Note that this format
    is not supported by the standard :py:func:`PIL.Image.open()` function.  To use
    this plugin, you have to import the :py:mod:`PIL.GdImageFile` module and
    use the :py:func:`PIL.GdImageFile.open()` function.
    ÚGDzGD uncompressed imagesÚreturnÚNonec                 C  sâ   | j d usJ ‚| j  d¡}t|ƒdvrd}t|ƒ‚d| _t|dƒt|dƒf| _t | j¡ |d }|r5dnd}t	|d	| ƒ}|d
k rG|| j
d< t d|d	| d d	| d d … ¡| _t dd| j d	| d d d¡g| _d S )Ni  )iþÿ  iÿÿ  zNot a valid GD 2.x .gd fileÚPé   é   é   r   é   é   ÚtransparencyÚRGBXi   Úraw)r   r   ÚL)ÚfpÚreadÚi16ÚSyntaxErrorÚ_modeÚ_sizer   Ú_decompression_bomb_checkÚsizeÚi32Úinfor   r   Úpaletter   Ú_TileÚtile)ÚselfÚsÚmsgÚ
true_colorÚtrue_color_offsetÚtindex© r-   úD/home/thesage/.local/lib/python3.10/site-packages/PIL/GdImageFile.pyÚ_open2   s.   
 ÿü
ÿzGdImageFile._openN)r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚformatÚformat_descriptionr/   r-   r-   r-   r.   r   '   s
    r   Úrr   úStrOrBytesPath | IO[bytes]ÚmodeÚstrr   c              
   C  sF   |dkr
d}t |ƒ‚zt| ƒW S  ty" } zd}t|ƒ|‚d}~ww )a#  
    Load texture from a GD image file.

    :param fp: 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 OSError: If the image could not be read.
    r6   zbad modezcannot identify this image fileN)Ú
ValueErrorr   r   r   )r   r8   r)   Úer-   r-   r.   ÚopenV   s   


€þr<   N)r6   )r   r7   r8   r9   r   r   )r3   Ú
__future__r   Útypingr   Ú r   r   r   r   Ú_binaryr	   r   r
   r"   Ú_typingr   r   r<   r-   r-   r-   r.   Ú<module>   s   /