U
    a+d7                     @   s    d Z ddlZdd Zdd ZdS )zs
This module implements all the functions to communicate with other Python
modules (PIL, matplotlib, mayavi, etc.)
    Nc                 C   s
   t | S )zt Transforms a PIL/Pillow image into a numpy RGB(A) image.
        Actually all this do is returning numpy.array(im).)nparray)Zim r   =/tmp/pip-unpacked-wheel-0yp4gafk/moviepy/video/io/bindings.pyPIL_to_npimage	   s    r   c           	      C   sf   ddl m} || }|  |jjj\}}}}t|t| }}| }tj	|tj
d}|||dS )zF Converts a matplotlib figure to a RGB frame after updating the canvasr   )FigureCanvasAgg)Zdtype   )Zmatplotlib.backends.backend_aggr   ZdrawfigureZbboxZboundsintZtostring_rgbr   Z
frombufferZuint8Zreshape)	Zfigr   Zcanvaslbwhbufimager   r   r   mplfig_to_npimage   s    r   )__doc__Znumpyr   r   r   r   r   r   r   <module>   s   	