o $aA@sldZddlZddlZddlmZdZdZeddZdZ d Z d e d ee fd d Z d e de d dfddZdS)z sphinx.util.png ~~~~~~~~~~~~~~~ PNG image manipulation helpers. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N)Optional !i s tEXtDepths IENDB`filenamereturncCst|d2}|tt d|t}|tts$ WddSt d|dddWdS1s:wYdS)zARead the special tEXt chunk indicating the depth from a PNG file.rbNrr) openseekLEN_IEND LEN_DEPTHread startswithDEPTH_CHUNK_LENDEPTH_CHUNK_STARTstructunpack)rf depthchunkr1/usr/lib/python3/dist-packages/sphinx/util/png.pyread_png_depths  $rdepthcCstd|}t|d0}|t d|tt|t t|d@}|td||t WddS1s>wYdS)zWrite the special tEXt chunk indicating the depth to a PNG file. The chunk is placed immediately before the special IEND chunk. rzr+br lz!IN) rpackr rrwriterrbinasciicrc32 IEND_CHUNK)rrdatarcrcrrrwrite_png_depth#s   "r$)__doc__rrtypingrrrrrrr!strintrr$rrrrs