
    Xh0                    V   d dl mZ d dlZddlmZmZmZ ddlmZ  ej	        d          Z
ddZ G d dej                  Z G d dej                  Z ej        ej        ee            ej        de            ej        ej        d            ej        ej        d           dS )    )annotationsN   )Image	ImageFileImagePalette)o8s$   "([0-9]*) ([0-9]*) ([0-9]*) ([0-9]*)prefixbytesreturnboolc                ,    |                      d          S )Ns	   /* XPM */)
startswith)r	   s    d/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/PIL/XpmImagePlugin.py_acceptr      s    \***    c                  &    e Zd ZdZdZddZdd	Zd
S )XpmImageFileXPMzX11 Pixel Mapr   Nonec                8   | j         J t          | j                             d                    sd}t          |          	 | j                                         }|sd}t          |          t
                              |          }|rnJt          |                    d                    t          |                    d                    f| _	        t          |                    d                    }t          |                    d                    }i }t          |          D ]6}| j                                                                         }|d|dz            }||dz   d	                                         }	t          d
t          |	          d          D ]}
|	|
         dk    r|	|
dz            }|dk    r|| j        d<   n|                    d          rZt          |dd          d          }t!          |dz	  dz            t!          |dz	  dz            z   t!          |dz            z   ||<   nd}t#          |           nd}t#          |          8|dk    rd| _        ||f}nid| _        t'          j        dd                    |                                                    | _        |t1          |                                          f}t5          j        dd| j        z   | j                                         |          g| _        d S )N	   znot an XPM fileTzbroken XPM filer            r      cs   Nonetransparency   #         zcannot read this XPM file   RGBPr   xpm)r   r   )fpr   readSyntaxErrorreadlinexpm_headmatchintgroup_sizerangerstripsplitleninfor   r   
ValueError_moder   rawjoinvaluespalettetuplekeysr   _Tilesizetelltile)selfmsglinempalette_lengthbppr9   _csirgbrgb_intargss                 r   _openzXpmImageFile._open'   s   w"""tw||A'' 	##Cc"""	7##%%D ''!#&&&t$$A 	 __c!''!**oo5
QWWQZZ!''!**oo
 ~&& 	& 	&A7##%%,,..DQq[!AS1Wr\"((**A1c!ffa(( & &Q44<<AE(Cg~~45	.11-- 
."%c!""gr"2"22455 'Q,#!5667 3//0  

 :(oo-E!  ( 2 oo%  CDJ>DDDJ'+E388GNN<L<L3M3MNNDLw||~~../D_UFTY,>PTUUV			r   
read_bytesr,   r
   c                      j         \  } j        J  fdt          |          D             }d                    |          S )Nc                ~    g | ]9}j                                         d d z                                          :S )r   )r&   r)   ljust).0rI   r@   xsizes     r   
<listcomp>z*XpmImageFile.load_read.<locals>.<listcomp>q   sB    RRRTWEAI.44U;;RRRr   r   )r=   r&   r/   r7   )r@   rN   ysizerH   rS   s   `   @r   	load_readzXpmImageFile.load_readj   sQ     yuw"""RRRRRU5\\RRRxx{{r   N)r   r   )rN   r,   r   r
   )__name__
__module____qualname__formatformat_descriptionrM   rV    r   r   r   r   #   sP        F(AW AW AW AWF	 	 	 	 	 	r   r   c                      e Zd ZdZddZdS )	
XpmDecoderTbuffer$bytes | Image.SupportsArrayInterfacer   tuple[int, int]c                   | j         J t                      }| j        \  }}| j        j        | j        j        z  }| j        dk    r|dz  }d}t          |          |k     r| j                                         }|sn|	                                dk    r|sd}Ld
                    |                    d          dd                   }t          d	t          |          |          D ]K}||||z            }	| j        dk    r|||	         z  }&|t          |                    |	                    z  }Lt          |          |k     |                     t!          |                     d
S )Nr#   r   Fs   /* pixels */T   "r   r   )rd   r   )fd	bytearrayrL   staterS   rU   moder2   r)   r0   r7   r1   r/   r   index
set_as_rawr
   )
r@   r_   datarE   r9   dest_lengthpixel_headerrB   rI   keys
             r   decodezXpmDecoder.decodey   sk   w"""{{yWj&)9991K$ii+%%7##%%D {{}}///#99TZZ--ad344D1c$ii-- 3 31q3w;'9%%GCL(DDBw}}S11222DD $ii+%% 	d$$$ur   N)r_   r`   r   ra   )rW   rX   rY   	_pulls_fdro   r\   r   r   r^   r^   v   s-        I     r   r^   r%   z.xpmz	image/xpm)r	   r
   r   r   )
__future__r   re r   r   r   _binaryr   compiler*   r   r   	PyDecoderr^   register_openrZ   register_decoderregister_extensionregister_mimer\   r   r   <module>r{      sE    # " " " " " 				 , , , , , , , , , ,       2:=>>+ + + +P P P P P9& P P Pf    $   D  L'w ? ? ?  uj ) ) )  ,f 5 5 5  L' 5 5 5 5 5r   