3
`JZ                 @   sp   d dl mZmZmZ d dlmZmZmZ	m
Z
 dZdd ZG dd dejZejejee ejejdd	g d
S )   )Image	ImageFileImagePalette)i8i16lei32leo8z0.2c             C   s    t | dkot| dd dkS )N          )r   r   )leni16)prefix r   4/usr/lib/python3/dist-packages/PIL/FliImagePlugin.py_accept   s    r   c               @   sX   e Zd ZdZdZdZdd Zdd Zedd	 Z	ed
d Z
dd Zdd Zdd ZdS )FliImageFileZFLIzAutodesk FLI/FLC AnimationFc             C   s  | j jd}t|dd }|d koFt|dd d!koF|d
d dksPtdt|dd | _d| _t|dd t|dd f| _t|dd
 }|dkr|d d }|| jd< dd t	dD }| j jd}d| _
t|dd dkr| j
t| | _
| j jd}t|dd dkrv| j jd}t|dd dkrT| j|d n"t|dd dkrv| j|d dd |D }tjddj|| _d"| _| j | _| j j | _| jd d S )#N   r
   r	                          s     znot an FLI/FLC file   P
      i  F   durationc             S   s   g | ]}|||fqS r   r   ).0ar   r   r   
<listcomp>B   s    z&FliImageFile._open.<locals>.<listcomp>   i   i        c             S   s*   g | ]"\}}}t |t | t | qS r   )r   )r#   rgbr   r   r   r%   U   s    ZRGB    r   )r   r   )r   r   )fpreadr   SyntaxError_FliImageFile__framecountmodesizei32inforange_FliImageFile__offset_paletter   rawjoinpalette_FliImageFile__frame_FliImageFile__fptell_FliImageFile__rewindseek)selfsmagicr"   r;   r   r   r   _open*   s>    "
zFliImageFile._openc       
      C   s   d}xt t| jjdD ]}| jjd}|t|d  }t|d }|dkrRd}| jj|d }xft dt|dD ]R}t|| |> }t||d  |> }t||d  |> }	|||	f||< |d7 }qtW qW d S )Nr   r(   r   r&   r   )r6   r   r.   r/   r   r   )
rA   r;   ZshiftierB   nr)   r*   r+   r   r   r   r8   ^   s    zFliImageFile._palettec             C   s   | j S )N)r1   )rA   r   r   r   n_framesp   s    zFliImageFile.n_framesc             C   s
   | j dkS )Nr   )r1   )rA   r   r   r   is_animatedt   s    zFliImageFile.is_animatedc             C   sN   | j |sd S || jk r"| jd x&t| jd |d D ]}| j| q8W d S )Nr   r   )Z_seek_checkr<   _seekr6   )rA   framefr   r   r   r@   x   s    


zFliImageFile.seekc             C   s   |dkr"d| _ | jj| j d| _|| j d kr<td| || _ | j| _| jj| j | jjd}|sltt	|}|| _
dd| j | jd fg| _|  j|7  _d S )	Nr   r   r   zcannot seek to frame %dr
   Zflir-   )r   r   )r<   r=   r@   r?   r7   
ValueErrorr.   r/   EOFErrorr4   Zdecodermaxblockr3   Ztile)rA   rK   rB   Z	framesizer   r   r   rJ      s     zFliImageFile._seekc             C   s   | j S )N)r<   )rA   r   r   r   r>      s    zFliImageFile.tellN)__name__
__module____qualname__formatZformat_descriptionZ!_close_exclusive_fp_after_loadingrD   r8   propertyrH   rI   r@   rJ   r>   r   r   r   r   r   $   s   4	r   z.fliz.flcN) r   r   r   Z_binaryr   r   r   r   r4   r   __version__r   r   Zregister_openrR   Zregister_extensionsr   r   r   r   <module>   s   }