def extract(cls, io): ext_bytes = cls.prefix while True: subblock = SubBlock.extract(io) ext_bytes += subblock.raw if subblock.raw[0] == "\x00": break return ext
def extract(cls, io): ext_bytes = "\x21\xff" block_size_bytes = io.read(1) block_size = int(block_size_bytes.encode("hex"), 16) ext_info = io.read(block_size) ext_bytes += block_size_bytes + ext_info while True: subblock = SubBlock.extract(io) ext_bytes += subblock.raw if subblock.raw[0] == "\x00": break return cls(ext_bytes)
def extract(cls, io): img_bytes = "\x2c" left = io.read(2) top = io.read(2) width = io.read(2) height = io.read(2) packed_byte = io.read(1) unpacked_bits = '{0:08b}'.format(int(packed_byte.encode("hex"), 16)) local_color_table_len = int(unpacked_bits[0]) * pow(2, int(unpacked_bits[4:], 2) + 1) local_color_table = io.read(3*local_color_table_len) lzw_min = io.read(1) img_bytes += left + top + width + height + packed_byte + local_color_table + lzw_min while True: subblock = SubBlock.extract(io) img_bytes += subblock.raw if subblock.raw[0] == "\x00": break img = cls(img_bytes) return img
def extract(cls, io): img_bytes = "\x2c" left = io.read(2) top = io.read(2) width = io.read(2) height = io.read(2) packed_byte = io.read(1) unpacked_bits = '{0:08b}'.format(int(packed_byte.encode("hex"), 16)) local_color_table_len = int(unpacked_bits[0]) * pow( 2, int(unpacked_bits[4:], 2) + 1) local_color_table = io.read(3 * local_color_table_len) lzw_min = io.read(1) img_bytes += left + top + width + height + packed_byte + local_color_table + lzw_min while True: subblock = SubBlock.extract(io) img_bytes += subblock.raw if subblock.raw[0] == "\x00": break img = cls(img_bytes) return img