o
    üÞhH  ã                   @  sh   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z
 ddlmZ G dd	„ d	ejƒZddd„ZdZdS )a�  
This reader is based on the specification available from:
https://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml
and has been tested with a few sample files found using google.

.. note::
    This format cannot be automatically recognized, so the reader
    is not registered for use with :py:func:`PIL.Image.open()`.
    To open a WAL file, use the :py:func:`PIL.WalImageFile.open()` function instead.
é    )Úannotations)ÚIOé   )ÚImageÚ	ImageFile)Úi32le)ÚStrOrBytesPathc                   @  s(   e Zd ZdZdZddd„Zddd	„Zd
S )ÚWalImageFileÚWALzQuake2 TextureÚreturnÚNonec                 C  s–   d| _ | j d¡}t|dƒt|dƒf| _t | j¡ t|dƒ}| j |¡ |d d…  	dd¡d | j
d	< |d
d…  	dd¡d }|rI|| j
d< d S d S )NÚPéd   é    é$   é(   ó    r   r   Únameé8   éX   Ú	next_name)Ú_modeÚfpÚreadÚi32Ú_sizer   Ú_decompression_bomb_checkÚsizeÚseekÚsplitÚinfo)ÚselfÚheaderÚoffsetr   © r$   úP/var/www/html/premium_crap/venv/lib/python3.10/site-packages/PIL/WalImageFile.pyÚ_open&   s   
ÿzWalImageFile._openúImage.core.PixelAccess | Nonec                 C  sV   | j d u r%tj | j| j¡| _|  | j 	| jd | jd  ¡¡ |  
t¡ tj | ¡S )Nr   r   )Ú_imr   ÚcoreÚnewÚmoder   ÚimÚ	frombytesr   r   Ú
putpaletteÚquake2paletteÚload)r!   r$   r$   r%   r0   8   s
   
"
zWalImageFile.loadN)r   r   )r   r'   )Ú__name__Ú
__module__Ú__qualname__ÚformatÚformat_descriptionr&   r0   r$   r$   r$   r%   r	   "   s
    
r	   ÚfilenameúStrOrBytesPath | IO[bytes]r   c                 C  s   t | ƒS )a2  
    Load texture from a Quake2 WAL texture file.

    By default, a Quake2 standard palette is attached to the texture.
    To override the palette, use the :py:func:`PIL.Image.Image.putpalette()` method.

    :param filename: WAL file name, or an opened file handle.
    :returns: An image instance.
    )r	   )r6   r$   r$   r%   Úopen@   s   
r8   s   """&&&))),,,///222555777:::<<<$" 


##&""%" #!"  -( )$'"%8.1),%& <07,3(-$("
10.,*'
%!


)#'!& %#! 

&# 

3"5)&7/-95479:379046+14'.1"+/(,%* &%"
 
,!!*)'&$"!


.0)-.'+,&**$()#''!&&$$""
0-,*(&$!



()8&'6%&4$$1""/ !-*'%!
/2)-0&+.$),!'*%(#&!%"

?<9 5#1#-#)?????9??1??*?? ???<?9?5?2?-=*;&9!742/-*'#=???<.*6' 0!)<9772/1,(+&!0" N)r6   r7   r   r	   )Ú__doc__Ú
__future__r   Útypingr   Ú r   r   Ú_binaryr   r   Ú_typingr   r	   r8   r/   r$   r$   r$   r%   Ú<module>   s   

þ