(self, data)
| 1659 | m(data) |
| 1660 | |
| 1661 | def _process_IHDR(self, data): |
| 1662 | # http://www.w3.org/TR/PNG/#11IHDR |
| 1663 | if len(data) != 13: |
| 1664 | raise FormatError("IHDR chunk has incorrect length.") |
| 1665 | ( |
| 1666 | self.width, |
| 1667 | self.height, |
| 1668 | self.bitdepth, |
| 1669 | self.color_type, |
| 1670 | self.compression, |
| 1671 | self.filter, |
| 1672 | self.interlace, |
| 1673 | ) = struct.unpack("!2I5B", data) |
| 1674 | |
| 1675 | check_bitdepth_colortype(self.bitdepth, self.color_type) |
| 1676 | |
| 1677 | if self.compression != 0: |
| 1678 | raise FormatError("Unknown compression method %d" % self.compression) |
| 1679 | if self.filter != 0: |
| 1680 | raise FormatError( |
| 1681 | "Unknown filter method %d," |
| 1682 | " see http://www.w3.org/TR/2003/REC-PNG-20031110/#9Filters ." |
| 1683 | % self.filter |
| 1684 | ) |
| 1685 | if self.interlace not in (0, 1): |
| 1686 | raise FormatError( |
| 1687 | "Unknown interlace method %d, see " |
| 1688 | "http://www.w3.org/TR/2003/REC-PNG-20031110/#8InterlaceMethods" |
| 1689 | " ." % self.interlace |
| 1690 | ) |
| 1691 | |
| 1692 | # Derived values |
| 1693 | # http://www.w3.org/TR/PNG/#6Colour-values |
| 1694 | colormap = bool(self.color_type & 1) |
| 1695 | greyscale = not (self.color_type & 2) |
| 1696 | alpha = bool(self.color_type & 4) |
| 1697 | color_planes = (3, 1)[greyscale or colormap] |
| 1698 | planes = color_planes + alpha |
| 1699 | |
| 1700 | self.colormap = colormap |
| 1701 | self.greyscale = greyscale |
| 1702 | self.alpha = alpha |
| 1703 | self.color_planes = color_planes |
| 1704 | self.planes = planes |
| 1705 | self.psize = float(self.bitdepth) / float(8) * planes |
| 1706 | if int(self.psize) == self.psize: |
| 1707 | self.psize = int(self.psize) |
| 1708 | self.row_bytes = int(math.ceil(self.width * self.psize)) |
| 1709 | # Stores PLTE chunk if present, and is used to check |
| 1710 | # chunk ordering constraints. |
| 1711 | self.plte = None |
| 1712 | # Stores tRNS chunk if present, and is used to check chunk |
| 1713 | # ordering constraints. |
| 1714 | self.trns = None |
| 1715 | # Stores sBIT chunk if present. |
| 1716 | self.sbit = None |
| 1717 | |
| 1718 | def _process_PLTE(self, data): |
nothing calls this directly
no test coverage detected