def thumbnail_to_buffer(self): """ Convert the thumbnail data as an RGB buffer. Returns: bytearray: RGB data of the thumbnail. """ self.unpack_thumb() status = ctypes.c_int(0) processed_image = self.libraw.libraw_dcraw_make_mem_thumb( self.data, ctypes.cast( ctypes.addressof(status), ctypes.POINTER(ctypes.c_int), ), ) raise_if_error(status.value) data_pointer = ctypes.cast( processed_image.contents.data, ctypes.POINTER(ctypes.c_byte * processed_image.contents.data_size) ) data = bytearray(data_pointer.contents) self.libraw.libraw_dcraw_clear_mem(processed_image) return data
def thumbnail_to_buffer(self): """ Convert the thumbnail data as an RGB buffer. Returns: bytearray: RGB data of the thumbnail. """ self.unpack_thumb() status = ctypes.c_int(0) processed_image = self.libraw.libraw_dcraw_make_mem_thumb( self.data, ctypes.cast( ctypes.addressof(status), ctypes.POINTER(ctypes.c_int), ), ) raise_if_error(status.value) data_pointer = ctypes.cast( processed_image.contents.data, ctypes.POINTER(ctypes.c_byte * processed_image.contents.data_size)) data = bytearray(data_pointer.contents) self.libraw.libraw_dcraw_clear_mem(processed_image) return data