B
    ÿ‹d   ã               @   sf   d Z ddlZddlZddlmZ dZdZe dd¡ZdZ	d	Z
eee d
œdd„Zeeddœdd„ZdS )zPNG image manipulation helpers.é    N)ÚOptionalé   é   z!ié
   s
   tEXtDepth s       IEND®B`‚)ÚfilenameÚreturnc          	   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ÚstructÚunpack)r   ÚfZ
depthchunk© r   ú\/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/sphinx/util/png.pyÚread_png_depth   s    
r   )r   Údepthr   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   ÚbinasciiÚcrc32Ú
IEND_CHUNK)r   r   Údatar   Úcrcr   r   r   Úwrite_png_depth   s    r"   )Ú__doc__r   r   Útypingr   r   r   r   r   r   r   ÚstrÚintr   r"   r   r   r   r   Ú<module>   s   