
    Fe                    j    d Z ddlmZ ddlZddlZdZdZ ej                  dd      ZdZ	d	Z
dd
ZddZy)zPNG image manipulation helpers.    )annotationsN      !i
   s
   tEXtDepth s       IENDB`c                0   t        | d      5 }|j                  t        t        z    d       |j	                  t              }|j                  t        t        z         s
	 ddd       yt        j                  d|dd       d   cddd       S # 1 sw Y   yxY w)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)filenamef
depthchunks      1/usr/lib/python3/dist-packages/sphinx/util/png.pyread_png_depthr      s    	h	 =	(Y&'+VVI&
$$_7H%HI= = ==z"R'89!<= = =s   AB'BBc                   t        j                  d|      }t        | d      5 }|j                  t         d       |j                  t        t        z   |z          t        j                  t        |z         dz  }|j                  t        j                  d|             |j                  t               ddd       y# 1 sw Y   yxY w)zWrite 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   depthdatar   crcs        r   write_png_depthr%      s    
 ;;tU#D	h	 	!	y!	"33d:;nn.56C	D#&'	
	 	 	s   BB<<C)r   strreturnz
int | None)r   r&   r"   intr'   None)__doc__
__future__r   r   r   r   r   r   r   r   r!   r   r%        r   <module>r.      sB    % "  	&++dB'$ 4
	=r-   