`data_blocks` should be an iterable that yields the compressed data (from the ``IDAT`` chunks). This yields decompressed byte strings.
(data_blocks)
| 2169 | |
| 2170 | |
| 2171 | def decompress(data_blocks): |
| 2172 | """ |
| 2173 | `data_blocks` should be an iterable that |
| 2174 | yields the compressed data (from the ``IDAT`` chunks). |
| 2175 | This yields decompressed byte strings. |
| 2176 | """ |
| 2177 | |
| 2178 | # Currently, with no max_length parameter to decompress, |
| 2179 | # this routine will do one yield per IDAT chunk: Not very |
| 2180 | # incremental. |
| 2181 | d = zlib.decompressobj() |
| 2182 | # Each IDAT chunk is passed to the decompressor, then any |
| 2183 | # remaining state is decompressed out. |
| 2184 | for data in data_blocks: |
| 2185 | # :todo: add a max_length argument here to limit output size. |
| 2186 | yield bytearray(d.decompress(data)) |
| 2187 | yield bytearray(d.flush()) |
| 2188 | |
| 2189 | |
| 2190 | def check_bitdepth_colortype(bitdepth, colortype): |