11 lines
563 B
JavaScript
11 lines
563 B
JavaScript
import CanvasKitInit from 'canvaskit-wasm';
|
|
const CK = await CanvasKitInit();
|
|
console.log('ImageFormat', JSON.stringify(CK.ImageFormat));
|
|
const surf = CK.MakeSurface(64, 64);
|
|
const c = surf.getCanvas(); c.clear(CK.Color(255,0,0,255));
|
|
const img = surf.makeImageSnapshot();
|
|
for (const k of Object.keys(CK.ImageFormat)) {
|
|
try { const b = img.encodeToBytes(CK.ImageFormat[k], 90); console.log(k, b ? b.length : null); } catch(e){ console.log(k, 'ERR', String(e).slice(0,80)); }
|
|
}
|
|
console.log('columns/readPixels', typeof img.readPixels, typeof img.encodeToBytes);
|