Using G开发者_StackOverflow中文版WT I would like to read a PNG image and have the data accessible to me as a decoded byte array.
On the client side I get the image using an ImageBundle, I then instantiate an Image and call setUrl.
At this point, how do I get the image byte array from the image?
You can't. Javascript (and hence GWT) do not have access to images' data when images are presented as html images (i.e. as <img>
tag or css background image).
What you could do is load image data via RPC, process it, Base64 encode it and then create image via embedded url: "data:image/png;base64,..yourBase64Datahere.."
If you are trying to do some visual manipulation you should consider:
Manipulating image on the server.
Using html
canvas
orsvg
.
精彩评论