ó
öŔ\c           @   s^   d  Z  d d l Z d d l Z d Z d Z e j d d  Z d Z d Z d	   Z	 d
   Z
 d S(   sŔ   
    sphinx.util.png
    ~~~~~~~~~~~~~~~

    PNG image manipulation helpers.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
i˙˙˙˙Ni   i   s   !ii
   s
   tEXtDepth s       IENDŽB`c      	   C   sr   t  |  d  ] } | j t t d  | j t  } | j t t  sM d St	 j
 d | d d ! d SWd QXd S(   sA   Read the special tEXt chunk indicating the depth from a PNG file.t   rbi   s   !ii   i   i    N(   t   opent   seekt   LEN_IENDt	   LEN_DEPTHt   readt
   startswitht   DEPTH_CHUNK_LENt   DEPTH_CHUNK_STARTt   Nonet   structt   unpack(   t   filenamet   ft
   depthchunk(    (    s.   lib/python2.7/site-packages/sphinx/util/png.pyt   read_png_depth   s    c         C   s   t  j d |  } t |  d  j } | j t d  | j t t |  t j	 t |  d @} | j t  j d |   | j t
  Wd QXd S(   s   Write the special tEXt chunk indicating the depth to a PNG file.

    The chunk is placed immediately before the special IEND chunk.
    s   !is   r+bi   I˙˙˙˙    s   !IN(   R
   t   packR   R   R   t   writeR   R   t   binasciit   crc32t
   IEND_CHUNK(   R   t   deptht   dataR   t   crc(    (    s.   lib/python2.7/site-packages/sphinx/util/png.pyt   write_png_depth%   s    (   t   __doc__R   R
   R   R   R   R   R   R   R   R   (    (    (    s.   lib/python2.7/site-packages/sphinx/util/png.pyt   <module>
   s   	