var imgs = mui("img"); if (imgs.length > 0) { var _x = 25; var _y = 50; var width = 300; var heigth = 300; for (var i = 0; i < imgs.length; i++) { var img = imgs[i]; if (img.getAttribute('data-type') == "content") { if (i == 0) { ctx.drawImage(img, _x, 50, width, heigth); } else { _y += heigth + 10; ctx.drawImage(img, _x, _y, width, heigth); } } } ctx.font = "16px 正楷"; ctx.fillText(Diary_Content, _x, 30); }
循环画图,最多的时候3张,画完以后,在最顶部画上标题。现在我如何通过JS获取画出来的这一整图。求指导。
toDataURL
cv.toDataURL? 还是document?
@问心、: cv
@MrLenon: 本地路径怎么获取。
@问心、: cv.toDataURL的返回值就是本地路径
@MrLenon: 我拿到的是这么一串。 data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAV4AAAPoCAYAAACWJ5ZbAAAgAElEQVR4Xuy9WbCm11Wm+Z15zpNzpjJTUqZsS0LIsjwI7KIYqooGXA0UNGasAhvP82ygqI6OqI7qvujoiO6Ijrrqq6ajqqeLuqmAKspAAabANsY2xgbbkjVaSqWU85nHfp937ff/f/v+nIuM75cyzvT/37e/tfde613vGvZY1796CfQS6CXQS+BQJTB2qHfrb9ZLoJdAL4FeAl2vePtF0Eugl0AvgUOWQK94D1ng/e16CfQS6CXQK95+DfQS6CXQS+CQJdAr3kMWeH+7XgK9BHoJ9Iq3XwO9BHoJ9BI4ZAn0iveQBd7frpdAL4FeAr3i7ddAL4FeAr0EDlkCveI9ZIH3t+sl0Eugl0CvePs10Eugl0AvgUOWQK94D1ng/e16CfQS6CXQK95+DfQS6CXQS+CQJdAr3kMWeH+7XgK9BHoJ9Iq3XwO9BHoJ9BI4ZAn0iveQBd7frpdAL4FeAr3i7ddAL4FeAr0EDlkCveI9ZIH3t+sl0Eugl0CvePs10Eugl0AvgUOWQK94D1ng/e16CfQS6CXQK95+DfQS6CXQS+CQJdAr3kMWeH+7XgK9BHoJ9Iq3XwO9BHoJ9BI4ZAn0iveQBd7frpdAL4FeAr3i7ddAL4FeAr0EDlkCveI9ZI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XZMbfVYu7u2bLN5yb5hIu1RaNCiYG1K8O7gL+j0CZIMvLS35vXa3US4gvoZEEBqbkL/tatGta4
@问心、: 对就是他
@MrLenon: 啊。我想要就是比如c://a.jpg这样的怎么获取。
@问心、: 这拿到的就是个图片啊,下一步无论是展示还是保存都可以啊
@MrLenon: 那我怎么才能拿到一个物理路径啊。
@问心、: 这个图片现在是没有物理路径的是存在内存的,你需要进行存储 click