Commit e6e2baa065fa6d8bb6c21884e205fccd7f47952d

Authored by wdn127929
1 parent c5795bf6

蒙版和限制字数

Showing 1 changed file with 17 additions and 4 deletions
@@ -2125,13 +2125,26 @@ class Utils { @@ -2125,13 +2125,26 @@ class Utils {
2125 // ..strokeCap = StrokeCap.butt 2125 // ..strokeCap = StrokeCap.butt
2126 // ..strokeWidth = 2; 2126 // ..strokeWidth = 2;
2127 final paint = Paint() 2127 final paint = Paint()
2128 - ..color = Color.fromRGBO(0, 0, 0, 0.8) 2128 + ..color = Color.fromRGBO(81, 81, 81, 0.4)
2129 ..style = PaintingStyle.fill; 2129 ..style = PaintingStyle.fill;
2130 2130
2131 - canvas.drawRect(Rect.fromLTWH(0, 0, 500, 400), paint); 2131 + // canvas.drawRect(Rect.fromLTWH(0, 0, 500, 400), paint);
2132 2132
2133 - canvas.drawImage(images, Offset(0, 0), paint);  
2134 - 2133 + // canvas.drawImage(images, Offset(0, 0), paint);
  2134 +
  2135 + // 定义源矩形,通常是图像的全部
  2136 + final Rect source = Rect.fromLTWH(0.0, 0.0, images.width.toDouble(), images.height.toDouble());
  2137 + // 定义目标矩形,即画布的大小
  2138 + final Rect destination = Rect.fromLTWH(0.0, 0.0, 500, 400);
  2139 + // 绘制图像
  2140 + canvas.drawImageRect(images, source, destination, paint);
  2141 +
  2142 + // 在画布上绘制图片,使用BoxFit来适配画布大小
  2143 + // canvas.drawImageRect(
  2144 + // images,
  2145 + // Rect.fromLTWH(0, 0, images.width.toDouble(), images.height.toDouble()),
  2146 + // Rect.fromLTWH(0, 0, images.width.toDouble(), images.height.toDouble()),
  2147 + // paint);
2135 2148
2136 // 绘制文字 2149 // 绘制文字
2137 ui.ParagraphBuilder pb2 = ui.ParagraphBuilder(ui.ParagraphStyle( 2150 ui.ParagraphBuilder pb2 = ui.ParagraphBuilder(ui.ParagraphStyle(