generate LVGL 9 binary

Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2025-12-06 21:08:52 +01:00
parent 187b42e465
commit d100221876
5 changed files with 127 additions and 4 deletions

View File

@@ -0,0 +1,45 @@
import 'package:image/image.dart' as img;
import 'package:injectable/injectable.dart';
@singleton
class ImageResizer {
static const int maxWidth = 480;
static const int maxHeight = 320;
img.Image resizeToFit(img.Image image) {
final w = image.width;
final h = image.height;
if (w <= maxWidth && h <= maxHeight) {
return image;
}
final aspectRatio = w / h;
int newWidth;
int newHeight;
if (w > h) {
newWidth = maxWidth;
newHeight = (maxWidth / aspectRatio).round();
if (newHeight > maxHeight) {
newHeight = maxHeight;
newWidth = (maxHeight * aspectRatio).round();
}
} else {
newHeight = maxHeight;
newWidth = (maxHeight * aspectRatio).round();
if (newWidth > maxWidth) {
newWidth = maxWidth;
newHeight = (maxWidth / aspectRatio).round();
}
}
return img.copyResize(
image,
width: newWidth,
height: newHeight,
interpolation: img.Interpolation.linear,
);
}
}