a
    1øaA  ã                   @   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À
    sphinx.util.png
    ~~~~~~~~~~~~~~~

    PNG image manipulation helpers.

    :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    N)ÚOptionalé   é   ú!ié
   s
   tEXtDepth s       IEND®B`‚)ÚfilenameÚreturnc                 C   sŽ   t | dƒp}| tt  d¡ | t¡}| tt ¡sFW d  ƒ dS t 	d|dd… ¡d W  d  ƒ S W d  ƒ n1 s€0    Y  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   ú.lib/python3.9/site-packages/sphinx/util/png.pyÚread_png_depth   s    
r   )r   Údepthr   c                 C   sˆ   t  d|¡}t| dƒ^}| t d¡ | tt | ¡ t 	t| ¡d@ }| t  d|¡¡ | t
¡ W d  ƒ n1 sz0    Y  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__r   r   Útypingr   r   r   r   r   r   r    ÚstrÚintr   r#   r   r   r   r   Ú<module>   s   
