MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / extractPixelData

Function extractPixelData

frontend/src/utility-functions/rasterization.ts:55–61  ·  view source on GitHub ↗
(imageData: ImageBitmapSource)

Source from the content-addressed store, hash-verified

53
54/// Convert an image source (e.g. PNG document) into pixel data, a width, and a height
55export 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
63export async function imageToCanvasContext(imageData: ImageBitmapSource): Promise<CanvasRenderingContext2D> {
64 // Special handling to rasterize an SVG file

Callers 2

triggerClipboardReadFunction · 0.90
pasteFileFunction · 0.90

Calls 1

imageToCanvasContextFunction · 0.85

Tested by

no test coverage detected