B
    -¦a›  ã               @   s4   d Z ddlZddlmZ ddlmZ 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.
é    Né   )ÚImage)Úi32lec          	   C   s:   dd„ }t | dƒr|| ƒS t | d¡
}||ƒS Q R X d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.
    c          	   S   sº   |   d¡}t|dƒt|dƒf}t|dƒ}|  |¡ t |¡ t d||   |d |d  ¡¡}| t¡ d|_d	|_	|d d…  
d
d¡d |jd< |dd…  
d
d¡d }|r¶||jd< |S )Néd   é    é$   é(   ÚPr   r   ZWALzQuake2 Textureó    Únameé8   éX   Ú	next_name)ÚreadÚi32Úseekr   Z_decompression_bomb_checkZ	frombytesZ
putpaletteÚquake2paletteÚformatÚformat_descriptionÚsplitÚinfo)ÚfpÚheaderÚsizeÚoffsetZimr   © r   ú4/tmp/pip-unpacked-wheel-rysjrues/PIL/WalImageFile.pyÚimopen-   s    



 

zopen.<locals>.imopenr   ÚrbN)ÚhasattrÚbuiltinsÚopen)Úfilenamer   r   r   r   r   r!       s
    
r!   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" )	Ú__doc__r    Ú r   Ú_binaryr   r   r!   r   r   r   r   r   Ú<module>   s
   .