Skip to content

Conversation

@yisibl
Copy link
Member

@yisibl yisibl commented Feb 28, 2024

Part of #300

Now you can pass the resvg-js rendered pixels to the canvas in the browser via new ImageData().

const resvgJS = new resvg.Resvg(svgString)
const pngData = resvgJS.render()
const imageData = new ImageData(pngData.pixels, pngData.width, pngData.height)

let canvas = document.createElement('canvas')
canvas.width = imageData.width
canvas.height = imageData.height

let ctx = canvas.getContext('2d')
ctx.putImageData(imageData, 0, 0)
document.body.appendChild(canvas)

@vercel
Copy link

vercel bot commented Feb 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
resvg-js ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2024 0:51am

asPng(): Buffer
/** Get the RGBA pixels of the image */
get pixels(): Buffer
get pixels(): Uint8ClampedArray
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Brooooooklyn napi-rs 可以直接生成 readonly pixels: Uint8ClampedArray 吗?

@yisibl yisibl requested a review from Brooooooklyn February 28, 2024 12:49
@yisibl yisibl marked this pull request as ready for review February 28, 2024 12:50
}
}
break
case 's390x':
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个新增的平台常见吗?我的 CI 还没有。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants