Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: .pixels return type changed to Uint8ClampedArray #304

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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)

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

@@ -44,7 +44,7 @@ export class RenderedImage {
/** Write the image data to Buffer */
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 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.

1 participant