commit
6e12e77f51
@ -438,15 +438,17 @@ class ImageModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final pid = parent.target?.id;
|
final pid = parent.target?.id;
|
||||||
ui.decodeImageFromPixels(
|
img.decodeImageFromPixels(
|
||||||
rgba,
|
rgba,
|
||||||
parent.target?.ffiModel.display.width ?? 0,
|
parent.target?.ffiModel.display.width ?? 0,
|
||||||
parent.target?.ffiModel.display.height ?? 0,
|
parent.target?.ffiModel.display.height ?? 0,
|
||||||
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888, (image) {
|
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888,
|
||||||
if (parent.target?.id != pid) return;
|
onPixelsCopied: () {
|
||||||
try {
|
|
||||||
// Unlock the rgba memory from rust codes.
|
// Unlock the rgba memory from rust codes.
|
||||||
platformFFI.nextRgba(id);
|
platformFFI.nextRgba(id);
|
||||||
|
}).then((image) {
|
||||||
|
if (parent.target?.id != pid) return;
|
||||||
|
try {
|
||||||
// my throw exception, because the listener maybe already dispose
|
// my throw exception, because the listener maybe already dispose
|
||||||
update(image);
|
update(image);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -11,6 +11,7 @@ Future<ui.Image> decodeImageFromPixels(
|
|||||||
int? rowBytes,
|
int? rowBytes,
|
||||||
int? targetWidth,
|
int? targetWidth,
|
||||||
int? targetHeight,
|
int? targetHeight,
|
||||||
|
VoidCallback? onPixelsCopied,
|
||||||
bool allowUpscaling = true,
|
bool allowUpscaling = true,
|
||||||
}) async {
|
}) async {
|
||||||
if (targetWidth != null) {
|
if (targetWidth != null) {
|
||||||
@ -22,6 +23,7 @@ Future<ui.Image> decodeImageFromPixels(
|
|||||||
|
|
||||||
final ui.ImmutableBuffer buffer =
|
final ui.ImmutableBuffer buffer =
|
||||||
await ui.ImmutableBuffer.fromUint8List(pixels);
|
await ui.ImmutableBuffer.fromUint8List(pixels);
|
||||||
|
onPixelsCopied?.call();
|
||||||
final ui.ImageDescriptor descriptor = ui.ImageDescriptor.raw(
|
final ui.ImageDescriptor descriptor = ui.ImageDescriptor.raw(
|
||||||
buffer,
|
buffer,
|
||||||
width: width,
|
width: width,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user