Gwt-query: get an Image from ImageData

970 views Asked by At

I'm trying to accomplish this but I've got no clue about getting a GWT Image from a Canvas ImageData. I'm issuing this piece of code:

ImageData canvasImageData = canvas.getContext2d().getImageData(0, 0, 500, 500);

My purpose is to get the Image somehow, any idea?

Thanks in advance!

1

There are 1 answers

0
dslh On BEST ANSWER

To create an Image from your canvas you should use Canvas.toDataUrl(), which will give you the image data encoded as a string which can be used as the src attribute for an <img> tag.

Image canvasImage = new Image(canvas.toDataUrl());