servo / pathfinder

A fast, practical GPU rasterizer for fonts and vector graphics
Apache License 2.0
3.62k stars 206 forks source link

getImageData and putImageData #388

Open leoyanggit opened 4 years ago

leoyanggit commented 4 years ago

Hi there! I wonder if we have plan to implement getImageData and pubImageDta like what browser has. Or are there already some APIs that can do that but I'm missing them?

s3bk commented 4 years ago

You can use draw_image for pubImageData. Getting it back is a bit more involved and not even possible on WebGL.

Pathfinder renders everything at once, so you will have to finish the Scene to render it and get the texture. See here for an example

leoyanggit commented 4 years ago

Currently I'm using readPixels for WebGL backend. Yes I need to build and render the scene before I do that.

pcwalton commented 4 years ago

I would like to implement them, yes. getImageData() will not be introspectable without consulting the Renderer, however, because the CanvasRenderingContext2D has no access to the raw pixel data.