Beispiel #1
0
class Chunk(bin.Chunk, encoding='ascii'):
    """
    A special chunk for PNG, which puts the size before the type
    and includes a CRC field for verifying data integrity.
    """
    size = bin.Integer(size=4)
    id = bin.String(size=4)
    payload = bin.Payload(size=size)
    crc = bin.CRC32(first=id)

    @property
    def is_critical(self):
        # Critical chunks will always have an uppercase letter for the
        # first character in the type. Ancillary will always be lower.
        return self.type[0].upper() == self.type[0]

    @property
    def is_public(self):
        # Public chunks will always have an uppercase letter for the
        # second character in the type. Private will always be lower.
        return self.type[1].upper() == self.type[1]
Beispiel #2
0
class Chunk(bin.Chunk):
    id = bin.String(size=4, encoding='ascii')
    size = bin.Integer(size=4)
    payload = bin.Payload(size=size)
Beispiel #3
0
class Form(bin.Chunk, encoding='ascii'):
    tag = bin.FixedString('FORM')
    size = bin.Integer(size=4)
    id = bin.String(size=4)
    payload = bin.Payload(size=size)
Beispiel #4
0
class ScanChunk(bin.Chunk):
    id = bin.Integer(size=2)
    size = bin.Integer(size=2)
    payload = bin.Payload(size=size - 2)
Beispiel #5
0
class EmptyChunk(bin.Chunk):
    id = bin.Integer(size=2)
    size = bin.Bytes(size=0)
    payload = bin.Payload(size=0)