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(),
|
||||
height: widget.layerData.image.height.toDouble(),
|
||||
padding: EdgeInsets.zero,
|
||||
color: Colors.green,
|
||||
color: Colors.transparent,
|
||||
child: CustomPaint(
|
||||
painter: UiImagePainter(scImage.image!),
|
||||
),
|
||||
|
|
@ -47,16 +47,25 @@ class UiImagePainter extends CustomPainter {
|
|||
|
||||
@override
|
||||
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(
|
||||
image,
|
||||
Rect.fromLTWH(0, 0, image.width.toDouble(), image.height.toDouble()),
|
||||
Rect.fromLTWH(0, 0, size.width, size.height),
|
||||
Rect.fromLTWH(0, 0, imageSize.width, imageSize.height),
|
||||
destRect,
|
||||
Paint(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
||||
return false;
|
||||
bool shouldRepaint(covariant UiImagePainter oldDelegate) {
|
||||
return image != oldDelegate.image;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue