mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
10 lines
359 B
TypeScript
10 lines
359 B
TypeScript
|
export const createImageFromImageData = (data: ImageData) => {
|
||
|
const canvas = document.createElement('canvas');
|
||
|
canvas.width = data.width;
|
||
|
canvas.height = data.height;
|
||
|
const ctx = canvas.getContext('2d')!;
|
||
|
ctx.putImageData(data, 0, 0);
|
||
|
const url = canvas.toDataURL('image/png');
|
||
|
return Buffer.from(url.split(',')[1], 'base64');
|
||
|
};
|