fromEncodedBuffer static method
Creates ImageRef from encoded buffer, e.g. from jpeg.
Implementation
static ImageRef? fromEncodedBuffer(Uint8List bytes,
{BufferImageLoadOptions? options}) {
return using((Arena arena) {
BufferImageLoadOptions resolvedOptions =
options ?? BufferImageLoadOptions();
Pointer<Uint8> pBytes = arena.allocate<Uint8>(bytes.length);
pBytes.asTypedList(bytes.length).setAll(0, bytes);
Pointer<CBufferImageLoadOptions> pConfig =
arena<CBufferImageLoadOptions>();
pConfig.ref.roi.x = resolvedOptions.roi.left;
pConfig.ref.roi.y = resolvedOptions.roi.top;
pConfig.ref.roi.width = resolvedOptions.roi.width;
pConfig.ref.roi.height = resolvedOptions.roi.height;
pConfig.ref.loadMode = resolvedOptions.loadMode.index;
String? uuid = _consumeString(
_nativeCreateFromEncodedBuffer(pBytes, bytes.length, pConfig));
if (uuid == null) {
return null;
}
ImageRef ref = ImageRef._(uuid);
return ref;
});
}