|
@@ -10,21 +10,38 @@ class VidPainter extends CustomPainter {
|
|
|
0, 1, 0, 0, 0,
|
|
|
0, 0, 1, 0, 0,
|
|
|
0, 0, 0, 1, 0,
|
|
|
- ]});
|
|
|
+ ],
|
|
|
+ this.enableScale = true});
|
|
|
ui.Image image;
|
|
|
int frameIndex;
|
|
|
List<double> colorFilterMatrix;
|
|
|
|
|
|
+
|
|
|
+ bool enableScale;
|
|
|
+
|
|
|
@override
|
|
|
void paint(Canvas canvas, Size size) async {
|
|
|
- final double scale = size.width / image.width;
|
|
|
- final double offsetY = (size.height - image.height * scale) / 2;
|
|
|
canvas.save();
|
|
|
- canvas.drawImageRect(
|
|
|
- image,
|
|
|
- Rect.fromLTWH(0, 0, image.width.toDouble(), image.height.toDouble()),
|
|
|
- Rect.fromLTWH(0, offsetY, size.width, image.height * scale),
|
|
|
- Paint()..colorFilter = ColorFilter.matrix(colorFilterMatrix));
|
|
|
+
|
|
|
+
|
|
|
+ if (enableScale) {
|
|
|
+ final double scale = size.width / image.width;
|
|
|
+ final double offsetY = (size.height - image.height * scale) / 2;
|
|
|
+ canvas.drawImageRect(
|
|
|
+ image,
|
|
|
+ Rect.fromLTWH(0, 0, image.width.toDouble(), image.height.toDouble()),
|
|
|
+ Rect.fromLTWH(0, offsetY, size.width, image.height * scale),
|
|
|
+ Paint()..colorFilter = ColorFilter.matrix(colorFilterMatrix));
|
|
|
+ } else {
|
|
|
+ final double offsetX = (size.width - image.width) / 2;
|
|
|
+ final double offsetY = (size.height - image.height) / 2;
|
|
|
+ canvas.drawImageRect(
|
|
|
+ image,
|
|
|
+ Rect.fromLTWH(0, 0, image.width.toDouble(), image.height.toDouble()),
|
|
|
+ Rect.fromLTWH(offsetX, offsetY, image.width.toDouble(),
|
|
|
+ image.height.toDouble()),
|
|
|
+ Paint()..colorFilter = ColorFilter.matrix(colorFilterMatrix));
|
|
|
+ }
|
|
|
canvas.restore();
|
|
|
}
|
|
|
|