
hR\                 @   s   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 Gd 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   G/var/www/dbchiro/venv/lib/python3.4/site-packages/PIL/FliImagePlugin.py_accept   s    r   c               @   s   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   sy  |  j  j d  } t | d d   } | d  k oc t | d d   d! k oc | d
 d  d k su t d   n  t | d d   |  _ d |  _ t | d d   t | d d   f |  _ t | d d
   } | d k r | d d } n  | |  j d <d d   t	 d  D } |  j  j d  } d |  _
 t | d d   d k r|  j
 t |  |  _
 |  j  j d  } n  t | d d   d k r|  j  j d  } t | d d   d k r|  j | d  qt | d d   d k r|  j | d  qn  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 Sr   r   ).0ar   r   r   
<listcomp>B   s   	 z&FliImageFile._open.<locals>.<listcomp>   i   i        c             S   s9   g  |  ]/ \ } } } t  |  t  |  t  |   q Sr   )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 } xt  t |  j j d    D] } |  j j d  } | t | d  } t | d  } | d k rv d } n  |  j j | d  } x t  d t |  d  D]g } t | |  | >} t | | d  | >} t | | d  | >}	 | | |	 f | | <| d 7} q Wq% Wd  S)Nr   r(   r   r&   r   )r6   r   r.   r/   r   r   )
rA   r;   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   sh   |  j  |  s d  S| |  j k  r2 |  j d  n  x/ t |  j d | d  D] } |  j |  qM Wd  S)Nr   r   )Z_seek_checkr<   _seekr6   )rA   framefr   r   r   r@   x   s    !zFliImageFile.seekc             C   s   | d k r4 d |  _  |  j j |  j  d |  _ n  | |  j  d k rZ t d |   n  | |  _  |  j |  _ |  j j |  j  |  j j d  } | s t  n  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   rL   rB   Z	framesizer   r   r   rK      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   propertyrI   rJ   r@   rK   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_openrS   Zregister_extensionsr   r   r   r   <module>   s   "}