def _read_additional_layer_info_block(fp): """ Reads a tagged block with additional layer information. """ sig = fp.read(4) if sig not in [b'8BIM', b'8B64']: fp.seek(-4, 1) #warnings.warn("not a block: %r" % sig) return key = fp.read(4) length = pad(read_fmt("I", fp)[0], 4) data = fp.read(length) return Block(key, data)
def _read_block(fp, encoding): """ Reads single image resource block. Such blocks contain non-pixel data for the images (e.g. pen tool paths). """ sig = fp.read(4) if sig != b"8BIM": raise Error("Invalid resource signature (%r)" % sig) resource_id = read_fmt("H", fp)[0] name = read_pascal_string(fp, encoding, 2) data_size = pad(read_fmt("I", fp)[0], 2) data = fp.read(data_size) return ImageResource(resource_id, name, data)
def _read_block(fp, encoding): """ Reads single image resource block. Such blocks contain non-pixel data for the images (e.g. pen tool paths). """ sig = fp.read(4) if sig not in [b'8BIM', b'MeSa']: raise Error("Invalid resource signature (%r)" % sig) resource_id = read_fmt("H", fp)[0] name = read_pascal_string(fp, encoding, 2) data_size = pad(read_fmt("I", fp)[0], 2) data = fp.read(data_size) return ImageResource(resource_id, name, data)
def _read_block(fp, encoding): """ Reads single image resource block. Such blocks contain non-pixel data for the images (e.g. pen tool paths). """ sig = fp.read(4) if not sig in (b'8BIM', b'MeSa'): raise Error("Invalid resource signature (%r)" % sig) resource_id = read_fmt("H", fp)[0] name = read_pascal_string(fp, encoding, 2) data_size = pad(read_fmt("I", fp)[0], 2) if not data_size: logger.debug( "Found image resource with no data (%d %s). Dropping..." % ( resource_id, ImageResourceID.name_of(resource_id) )) return None data = fp.read(data_size) return ImageResource(resource_id, name, data)
def _read_additional_layer_info_block(fp, padding): """ Reads a tagged block with additional layer information. """ sig = fp.read(4) if sig not in (b'8BIM', b'8B64'): raise Error("Invalid signature of tagged block (%r)" % sig) key = fp.read(4) length = read_fmt("I", fp)[0] if not length: logger.debug( "Found tagged block with no data (%s %s). Dropping..." % ( key, TaggedBlock.name_of(key) )) return None if padding > 0: length = pad(length, padding) data = fp.read(length) return Block(key, data)
def _read_additional_layer_info_block(fp, padding, version): """ Reads a tagged block with additional layer information. """ sig = fp.read(4) if sig not in [b'8BIM', b'8B64']: fp.seek(-4, 1) #warnings.warn("not a block: %r" % sig) return key = fp.read(4) if version == 2 and key in (b'LMsk', b'Lr16', b'Lr32', b'Layr', b'Mt16', b'Mt32', b'Mtrn', b'Alph', b'FMsk', b'lnk2', b'FEid', b'FXid', b'PxSD'): length = read_fmt("Q", fp)[0] else: length = read_fmt("I", fp)[0] if padding > 0: length = pad(length, padding) data = fp.read(length) return Block(key, data)