evanw / glfx.js

An image effects library for JavaScript using WebGL
https://evanw.github.io/glfx.js/
MIT License
3.28k stars 403 forks source link

Can not export the modified image #24

Open glumb opened 9 years ago

glumb commented 9 years ago

I'm trying to export an image from the canvas using canvas.toDataURL(). This does not work for me on Chrome nor Firefox. Also the 'canvas.toDataURL.html' test does not show a second exported image.

How to export or save a screenshot of the canvas the right way?

glumb commented 9 years ago

I discovered, that it works, if we use the toDataUrl method which was removed in a8a03b40aa0cc1a822291aa6538efcd5f27b3de9

stuarteaton commented 9 years ago

Can you give an example of how you got this to work. I am struggling to export the canvas to an image.

glumb commented 9 years ago

Hey @stuarteaton, add the method a8a03b40aa0cc1a822291aa6538efcd5f27b3de9 back to the source and try something like this:

that.renderingCanvas = fx.canvas();
that.renderingCanvas.draw(texture).perspective( //or any other transform
                    [0, 0, w, 0, 0, h, w, h],
                    points
                ).update();
that.renderingCanvas.toDataURL()
Dineshruhela commented 5 years ago

Hi @glumb, I am also facing the same issue and I'm using npm package of glfx.js with react where exactly should I add metthod back to the source that.renderingCanvas = fx.canvas(); that.renderingCanvas.draw(texture).perspective( //or any other transform [0, 0, w, 0, 0, h, w, h], points ).update(); that.renderingCanvas.toDataURL()