Convert and insert Base64 data to Canvas in Javascript(在 Javascript 中将 Base64 数据转换并插入到 Canvas)
问题描述
我得到一个数据缓冲区,代表 Base64 中的图像.我得到的数据(以base64表示图像)(部分数据)
<代码> 193,1181,25,21,211 ,111111,211,2111111111111111111111111111118.11111111111151515151584,103,136,198,74,212,41,171,203,188,187,69,121,183,255,0,7,75,156,191,140,190,45,181,219,141,43,195,214,107,30,129,3,145,38,110,60,135,185,35,130,119,4,108,244,238,0,227,3,140,86,85,237,134,149,241,3,69,158,251,71,134,93,31,88,211,72,82,1,30,100,76,70,65,12,9,12,141,207,94,184,32,140,215,45,47,196,111,130,177,187,34,120,79,197,65,84,224,8,175,03,20,97,426,785,141,47,227,159,195,111,11,219,223,46,133,225,175,17,91,73,120,170,178,189,196,137,49,96,185,218,50,247,44,64,27,155,167,173,123,252,61,144,97,242,8,63,102,156,234,207,227,169,43,115,77,245,230,119,122,111,104,173,23,78,167,204,103,121,165,108,217,46,88,184,40,124 .....代码>
成功解码.
现在我正在尝试将图像添加到我的画布但没有成功,如下所示:
function fillCanvasImage(x, y, width, height, image, pageID) {如果(图像==")返回;var canvas = document.getElementById("AppPmainCanvas" + pageID);if (canvas && canvas.getContext) {var context = canvas.getContext('2d');如果(上下文){context.clearRect(0, 0, canvas.width, canvas.height);var img = new Image();img.src = base64_decode(图像);//img.onload = function () {context.drawImage(img, 0, 0, canvas.width, canvas.height);/
本文标题为:在 Javascript 中将 Base64 数据转换并插入到 Canvas
基础教程推荐
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01