o
    N i¤  ã                   @  sT   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„Zddd„ZdS )zPNG image manipulation helpers.é    )ÚannotationsNé   é   ú!ié
   s
   tEXtDepth s       IEND®B`‚ÚfilenameÚstrÚreturnú
int | Nonec                 C  s‚   t | dƒ2}| tt  d¡ | t¡}| tt ¡s$	 W d  ƒ dS t 	d|dd… ¡d W  d  ƒ S 1 s:w   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   ÚfÚ
depthchunk© r   úC/home/ubuntu/.local/lib/python3.10/site-packages/sphinx/util/png.pyÚread_png_depth   s   
û$ùr   ÚdepthÚintÚNonec                 C  sŠ   t  d|¡}t| dƒ0}| t d¡ | tt | ¡ t 	t| ¡d@ }| t  d|¡¡ | t
¡ W d  ƒ dS 1 s>w   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(   )r   r   r	   r
   )r   r   r   r   r	   r    )Ú__doc__Ú
__future__r   r#   r   r   r   r!   r   r   r%   r   r(   r   r   r   r   Ú<module>   s    
