vtk.js

vtk.js


base64 转 imageData

<pre><code class="language-javascript">/** * * @param {*} base64 */ export async function base64ToImageDataRGB(base64, width, height) { return new Promise((resolve, reject) =&amp;gt; { const img = document.createElement('img'); img.onload = function () { const offscreenC = new OffscreenCanvas(width, height); const context = offscreenC.getContext('2d'); context.drawImage(img, 0, 0); let imgData = context.getImageData(0, 0, width, height); let arrData = imgData.data.filter((item, index) =&amp;gt; { if ((index + 1) % 4 === 0) { return false; } return true; }); imgData = null; arrData = new Uint8Array(arrData); resolve(arrData); }; img.src = base64; }); }</code></pre>

页面列表

ITEM_HTML