开发者

Manipulating pixels using only toDataURL

The problem I have is this: I need to be able to dynamically tint an image using Javascript, but I cannot access pixel data via the canvas. I can, however, store the dataURL (or any other text-based data format) and include that with the code, manipulate that data, and then create an image object using that dataURL.

My question is, how can I access the RGBA value of each pixel, given only the dataURL. I assume I need to decode the base64 url, but into what format in order to manipulate on the pixel level? And then would开发者_如何转开发 be it be as trivial as re-encoding it as base64, slapping it in a url, and the passing to an image?

Thanks.


I've implemented a toDataURL/PNG replacement over at xda that may serve your needs. It operates on an RGBA array, so you could include your image as an uncompressed resource, load it into an array using a simple XMLHttpRequest, manipulate it and finally feed it into that function to get a drawable DataURL

http://forum.xda-developers.com/showthread.php?t=1251575

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜