mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-03-03 17:06:47 +00:00
fix #390
This commit is contained in:
parent
a029d2f4d5
commit
77166253ae
1 changed files with 14 additions and 5 deletions
|
|
@ -33,7 +33,7 @@ class _BackgroundLayerState extends State<BackgroundLayer> {
|
||||||
width: widget.layerData.image.width.toDouble(),
|
width: widget.layerData.image.width.toDouble(),
|
||||||
height: widget.layerData.image.height.toDouble(),
|
height: widget.layerData.image.height.toDouble(),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
color: Colors.green,
|
color: Colors.transparent,
|
||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
painter: UiImagePainter(scImage.image!),
|
painter: UiImagePainter(scImage.image!),
|
||||||
),
|
),
|
||||||
|
|
@ -47,16 +47,25 @@ class UiImagePainter extends CustomPainter {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
|
final imageSize = Size(image.width.toDouble(), image.height.toDouble());
|
||||||
|
|
||||||
|
final sizes = applyBoxFit(BoxFit.contain, imageSize, size);
|
||||||
|
|
||||||
|
final destRect = Alignment.center.inscribe(
|
||||||
|
sizes.destination,
|
||||||
|
Rect.fromLTWH(0, 0, size.width, size.height),
|
||||||
|
);
|
||||||
|
|
||||||
canvas.drawImageRect(
|
canvas.drawImageRect(
|
||||||
image,
|
image,
|
||||||
Rect.fromLTWH(0, 0, image.width.toDouble(), image.height.toDouble()),
|
Rect.fromLTWH(0, 0, imageSize.width, imageSize.height),
|
||||||
Rect.fromLTWH(0, 0, size.width, size.height),
|
destRect,
|
||||||
Paint(),
|
Paint(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
bool shouldRepaint(covariant UiImagePainter oldDelegate) {
|
||||||
return false;
|
return image != oldDelegate.image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue