Reduce app size

This commit is contained in:
2025-01-24 18:06:23 +08:00
parent 6b0a5184b9
commit 7bd0c2b82a
5 changed files with 364 additions and 114 deletions

View File

@@ -26,7 +26,7 @@ class Image {
var codec = await ui.instantiateImageCodec(data);
var frame = await codec.getNextFrame();
codec.dispose();
var info = await frame.image.toByteData();
var info = await frame.image.toByteData(format: ui.ImageByteFormat.rawStraightRgba);
if (info == null) {
throw Exception('Failed to decode image');
}
@@ -39,6 +39,14 @@ class Image {
return image;
}
int getPixelAtIndex(int index) {
if (index < 0 || index >= _data.length) {
throw ArgumentError(
'Invalid argument: index must be in the range of [0, ${_data.length}).');
}
return _data[index];
}
Image copyRange(int x, int y, int width, int height) {
if (width + x > this.width) {
throw ArgumentError('''