android - 如何在android studio中的webview内画一条线
问题描述
下面的代码在我的 webview 中给了我位图
Bitmap bitmap = bm;
String html="<html><body><img src='dicomFile' /></body></html>";
// Convert bitmap to Base64 encoded image for web
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
String imgageBase64 = Base64.encodeToString(byteArray, Base64.DEFAULT);
String image = "data:image/png;base64," + imgageBase64;
// Use image for the img src parameter in your html and load to webview
html = html.replace("dicomFile", image);
imageView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", "");
imageView.getSettings().setBuiltInZoomControls(true);
我尝试使用下面的代码在 webview 内画线但不工作
paint=new Paint();
canvas.drawLine(50,128, 300, 128, paint);
imageView.draw(canvas);
现在我需要在这个图像内画线。这怎么可能?
解决方案
推荐阅读
- c# - 在net6.0-windows中不能为windows窗体添加windows media player
- node.js - 为什么 return 在 NodeJS/Electron 中不起作用
- docusignapi - 获取模板的所有信封的最佳方法是什么?
- python - 在 Python 中从 UTF16 LE 转换为 ANSI
- r - 什么方法分析汇总数据
- linux - ll -a时如何在Linux中的目录信息前面显示'->'?
- jquery - 如何使用jquery选择所有元素,其中类以名称开头,中间有通配符并以名称结尾?检查多个类
- python - 添加两个列表的值并将总和为零
- modelica - 在 Modelica 中,如何在不连接 2 个块的情况下调用不同块中的变量?
- java - 创建了带有多个复选框的 Jpanel 并呈现到 JTable 单元格导致问题