Implementation
static RawImageF fromImage(imglib.Image image, {Format format = Format.FORMAT_RGB}) {
if (!_formatMap.containsKey(format)) throw Exception("Unsuport image format");
Uint8List data = image.getBytes(order: _formatMap[format]!);
Pointer<Uint8> dataPtr = malloc.allocate(data.length);
if (dataPtr.address == nullptr.address)
throw Exception("RawImageF.fromImage: Failed to allocate a ${data.length} bytes");
Uint8List rawImgData = dataPtr.cast<Uint8>().asTypedList(data.length);
rawImgData.setAll(0, data);
return RawImageF(image.width, image.height, format, dataPtr.cast());
}