B
    öÀ„\V  ã               @   sD   d Z ddlZddlZdZdZe dd¡ZdZdZd	d
„ Z	dd„ Z
dS )zÀ
    sphinx.util.png
    ~~~~~~~~~~~~~~~

    PNG image manipulation helpers.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    Né   é   z!ié
   s
   tEXtDepth s       IEND®B`‚c          	   C   s`   t | dƒL}| tt  d¡ | t¡}| tt ¡s:dS t 	d|dd… ¡d S W dQ R X dS )zARead the special tEXt chunk indicating the depth from a PNG file.Úrbé   Nz!ié   é   r   )
ÚopenÚseekÚLEN_IENDÚ	LEN_DEPTHÚreadÚ
startswithÚDEPTH_CHUNK_LENÚDEPTH_CHUNK_STARTÚstructZunpack)ÚfilenameÚfZ
depthchunk© r   ú.lib/python3.7/site-packages/sphinx/util/png.pyÚread_png_depth   s    
r   c          	   C   st   t  d|¡}t| dƒT}| t d¡ | tt | ¡ t 	t| ¡d@ }| t  d|¡¡ | t
¡ W dQ R X dS )z‰Write the special tEXt chunk indicating the depth to a PNG file.

    The chunk is placed immediately before the special IEND chunk.
    z!izr+br   l   ÿÿ z!IN)r   Úpackr	   r
   r   Úwriter   r   ÚbinasciiZcrc32Ú
IEND_CHUNK)r   ZdepthÚdatar   Zcrcr   r   r   Úwrite_png_depth%   s    r   )Ú__doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r   Ú<module>
   s   