U
    \ªSh¥  ã                   @  sb   d Z ddlmZ ddlZddlZdZdZe dd¡ZdZ	d	Z
d
ddœdd„Zd
dddœdd„ZdS )zPNG image manipulation helpers.é    )ÚannotationsNé   é   ú!ié
   s
   tEXtDepth s       IEND®B`‚Ústrz
int | None)ÚfilenameÚreturnc              
   C  sv   t | dƒb}| tt  d¡ | t¡}| tt ¡sDW 5 Q R £ dS t 	d|dd… ¡d W  5 Q R £ S W 5 Q R X dS )zARead the special tEXt chunk indicating the depth from a PNG file.Úrbé   Nr   é   é   r   )
ÚopenÚseekÚLEN_IENDÚ	LEN_DEPTHÚreadÚ
startswithÚDEPTH_CHUNK_LENÚDEPTH_CHUNK_STARTÚstructÚunpack)r   ÚfZ
depthchunk© r   úB/root/rtd-docs/venv/lib/python3.8/site-packages/sphinx/util/png.pyÚread_png_depth   s    
r   ÚintÚNone)r   Údepthr	   c              	   C  st   t  d|¡}t| dƒT}| t d¡ | tt | ¡ t 	t| ¡d@ }| t  d|¡¡ | t
¡ W 5 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.
    r   z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__Ú
__future__r   r!   r   r   r   r   r   r   r#   r   r&   r   r   r   r   Ú<module>   s   