颤音:用drawnlines使用定制器绘制图像
我正在处理的应用程序的一部分涉及编辑照片。我试图包括一个绘制图像的选项。我找不到有关如何在Github或文档上执行此操作的任何示例。
这就是我到目前为止所拥有的:
class Sketcher extends CustomPainter {
final List<DrawnLine> lines;
final ui.Image image;
final BuildContext context;
Sketcher({required this.lines, required this.image,});
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint()
..color = Colors.redAccent
..strokeCap = StrokeCap.round
..strokeWidth = 5.0;
for (int i = 0; i < lines.length; ++i) {
if (lines[i] == null) continue;
for (int j = 0; j < lines[i].path.length - 1; ++j) {
if (lines[i].path[j] != null && lines[i].path[j + 1] != null) {
paint.color = lines[i].color;
paint.strokeWidth = lines[i].width;
canvas.drawLine(lines[i].path[j], lines[i].path[j + 1], paint);
}
}
}
// Add DrawnLine to image
}
@override
bool shouldRepaint(Sketcher oldDelegate) {
return true;
}
}
目前,我正在stack
窗口小部件中显示图像上的绘制线路。
是否可以通过修改图像的线条将画布与图像结合在一起?
我已经知道canvas.drawimage(),但是我还没有找到任何有效的代码,也没有人在网上在任何地方都有类似的问题。
A part of an application I am working on involves editing photos. I am attempting to include an option to draw on an image. I can not find any examples of how to do this on Github or with the documentation.
This is what I have so Far:
class Sketcher extends CustomPainter {
final List<DrawnLine> lines;
final ui.Image image;
final BuildContext context;
Sketcher({required this.lines, required this.image,});
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint()
..color = Colors.redAccent
..strokeCap = StrokeCap.round
..strokeWidth = 5.0;
for (int i = 0; i < lines.length; ++i) {
if (lines[i] == null) continue;
for (int j = 0; j < lines[i].path.length - 1; ++j) {
if (lines[i].path[j] != null && lines[i].path[j + 1] != null) {
paint.color = lines[i].color;
paint.strokeWidth = lines[i].width;
canvas.drawLine(lines[i].path[j], lines[i].path[j + 1], paint);
}
}
}
// Add DrawnLine to image
}
@override
bool shouldRepaint(Sketcher oldDelegate) {
return true;
}
}
At the moment I am displaying the Drawn Lines over the Image in a Stack
Widget.
Is there a way to combine the canvas with the Image by amending the lines to the Image?
I already know about canvas.drawImage() however I haven't found any code that works and no one is having a similar issue anywhere online.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论