loadImage method
Implementation
Future<PImage> loadImage(String filepath) async {
final imageData = await _assetBundle!.load(filepath);
final codec = await (await ImageDescriptor.encoded(
await ImmutableBuffer.fromUint8List(imageData.buffer.asUint8List()),
))
.instantiateCodec();
final frame = await codec.getNextFrame();
return PImage.fromPixels(
frame.image.width,
frame.image.height,
(await frame.image.toByteData())!,
// TODO: choose image type by extension
ImageFileFormat.png,
);
}