(imageData: ImageBitmapSource)
| 53 | |
| 54 | /// Convert an image source (e.g. PNG document) into pixel data, a width, and a height |
| 55 | export async function extractPixelData(imageData: ImageBitmapSource): Promise<ImageData> { |
| 56 | const canvasContext = await imageToCanvasContext(imageData); |
| 57 | const width = canvasContext.canvas.width; |
| 58 | const height = canvasContext.canvas.height; |
| 59 | |
| 60 | return canvasContext.getImageData(0, 0, width, height); |
| 61 | } |
| 62 | |
| 63 | export async function imageToCanvasContext(imageData: ImageBitmapSource): Promise<CanvasRenderingContext2D> { |
| 64 | // Special handling to rasterize an SVG file |
no test coverage detected