mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-27 23:19:02 +08:00
ensure nextRgba called no matter if image created
This commit is contained in:
parent
c27791a9ac
commit
47143318ba
@ -13,13 +13,14 @@ Future<ui.Image?> decodeImageFromPixels(
|
|||||||
int? rowBytes,
|
int? rowBytes,
|
||||||
int? targetWidth,
|
int? targetWidth,
|
||||||
int? targetHeight,
|
int? targetHeight,
|
||||||
VoidCallback? onPixelsCopied,
|
VoidCallback? onPixelsCopied, // must ensure onPixelsCopied is called no matter this function succeeds
|
||||||
bool allowUpscaling = true,
|
bool allowUpscaling = true,
|
||||||
}) async {
|
}) async {
|
||||||
if (targetWidth != null) {
|
if (targetWidth != null) {
|
||||||
assert(allowUpscaling || targetWidth <= width);
|
assert(allowUpscaling || targetWidth <= width);
|
||||||
if (!(allowUpscaling || targetWidth <= width)) {
|
if (!(allowUpscaling || targetWidth <= width)) {
|
||||||
print("not allow upscaling but targetWidth > width");
|
print("not allow upscaling but targetWidth > width");
|
||||||
|
onPixelsCopied?.call();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,6 +28,7 @@ Future<ui.Image?> decodeImageFromPixels(
|
|||||||
assert(allowUpscaling || targetHeight <= height);
|
assert(allowUpscaling || targetHeight <= height);
|
||||||
if (!(allowUpscaling || targetHeight <= height)) {
|
if (!(allowUpscaling || targetHeight <= height)) {
|
||||||
print("not allow upscaling but targetHeight > height");
|
print("not allow upscaling but targetHeight > height");
|
||||||
|
onPixelsCopied?.call();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,6 +38,7 @@ Future<ui.Image?> decodeImageFromPixels(
|
|||||||
buffer = await ui.ImmutableBuffer.fromUint8List(pixels);
|
buffer = await ui.ImmutableBuffer.fromUint8List(pixels);
|
||||||
onPixelsCopied?.call();
|
onPixelsCopied?.call();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
onPixelsCopied?.call();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user