o
    üÞh²  ã                   @  sš   d dl mZ d dlZddlmZmZmZ ddlmZ	 ddlm
Z ddlmZ ddlmZ ddd„ZG dd„ dejƒZe ejee¡ e ejddg¡ dS )é    )ÚannotationsNé   )ÚImageÚ	ImageFileÚImagePalette)Úi16le)Úi32le©Úo8)ÚDeferredErrorÚprefixÚbytesÚreturnÚboolc                 C  s(   t | ƒdkot| dƒdv ot| dƒdv S )Né   é   )é¯  i¯  é   )r   é   )ÚlenÚi16)r   © r   úR/var/www/html/premium_crap/venv/lib/python3.10/site-packages/PIL/FliImagePlugin.pyÚ_accept   s
   ÿýr   c                   @  sJ   e Zd ZdZdZdZddd„Zddd„Zddd„Zddd„Z	ddd„Z
dS )ÚFliImageFileÚFLIzAutodesk FLI/FLC AnimationFr   ÚNonec           
      C  sÈ  | j  d¡}t|ƒr|dd… dksd}t|ƒ‚t|dƒ| _| jdk| _d| _t|d	ƒt|d
ƒf| _t	|dƒ}t|dƒ}|dkrF|d d }|| j
d< dd„ tdƒD ƒ}| j  d¡}d| _t|dƒdkry| jt	|ƒ | _| j  | j¡ | j  d¡}t|dƒdkrÁt|dƒ}d }t|ƒD ]5}|d ur›| j  |d tj¡ | j  d¡}t|dƒ}	|	dv r¸|  ||	dkr³dnd¡  n	t	|ƒ}|sÀ nq‹t dd dd„ |D ƒ¡¡| _d| _| j | _| j  ¡ | _|  d¡ d S )Né€   é   é   s     znot an FLI/FLC filer   r   ÚPé   é
   é   r   r   iè  éF   Údurationc                 S  s   g | ]}|||f‘qS r   r   )Ú.0Úar   r   r   Ú
<listcomp>H   s    z&FliImageFile._open.<locals>.<listcomp>é   i ñ  iúñ  )r   é   r*   é   r   ÚRGBó    c                 s  s.   � | ]\}}}t |ƒt |ƒ t |ƒ V  qd S ©Nr	   )r&   ÚrÚgÚbr   r   r   Ú	<genexpr>e   s   €, z%FliImageFile._open.<locals>.<genexpr>éÿÿÿÿ)ÚfpÚreadr   ÚSyntaxErrorr   Ún_framesÚis_animatedÚ_modeÚ_sizeÚi32ÚinfoÚrangeÚ_FliImageFile__offsetÚseekÚosÚSEEK_CURÚ_paletter   ÚrawÚjoinÚpaletteÚ_FliImageFile__frameÚ_fpÚtellÚ_FliImageFile__rewind)
ÚselfÚsÚmsgr%   ÚmagicrE   Únumber_of_subchunksÚ
chunk_sizeÚ_Ú
chunk_typer   r   r   Ú_open1   sT   




ÿÿzFliImageFile._openrE   úlist[tuple[int, int, int]]ÚshiftÚintc           
      C  s¶   d}t t| j d¡ƒƒD ]L}| j d¡}||d  }|d }|dkr$d}| j |d ¡}t dt|ƒdƒD ]#}|| |> }||d  |> }||d  |> }	|||	f||< |d7 }q4qd S )Nr   r+   r   r)   r   )r=   r   r4   r5   r   )
rJ   rE   rT   ÚiÚerK   Únr/   r0   r1   r   r   r   rB   n   s    
ûùzFliImageFile._paletteÚframec                 C  sJ   |   |¡sd S || jk r|  d¡ t| jd |d ƒD ]}|  |¡ qd S )Nr   r   )Ú_seek_checkrF   Ú_seekr=   )rJ   rY   Úfr   r   r   r?   €   s   


ÿzFliImageFile.seekc                 C  sÒ   t | jtƒr
| jj‚|dkrd| _| j | j¡ d| _n|  ¡  || jd kr0d|› �}t	|ƒ‚|| _| j| _
| j
 | j¡ | j
 d¡}|sLd}t|ƒ‚t|ƒ}|| _t dd	| j | j¡g| _|  j|7  _d S )
Nr   r3   r   r   zcannot seek to frame r   zmissing frame sizeÚfli)r   r   )Ú
isinstancerG   r   ÚexrF   r?   rI   r>   ÚloadÚ
ValueErrorr4   r5   ÚEOFErrorr;   Údecodermaxblockr   Ú_TileÚsizeÚtile)rJ   rY   rL   rK   Ú	framesizer   r   r   r[   ‰   s*   
zFliImageFile._seekc                 C  s   | j S r.   )rF   )rJ   r   r   r   rH   ©   s   zFliImageFile.tellN)r   r   )rE   rS   rT   rU   r   r   )rY   rU   r   r   )r   rU   )Ú__name__Ú
__module__Ú__qualname__ÚformatÚformat_descriptionÚ!_close_exclusive_fp_after_loadingrR   rB   r?   r[   rH   r   r   r   r   r   ,   s    

=

	 r   z.fliz.flc)r   r   r   r   )Ú
__future__r   r@   Ú r   r   r   Ú_binaryr   r   r   r;   r
   Ú_utilr   r   r   Úregister_openrk   Úregister_extensionsr   r   r   r   Ú<module>   s   
 