开发者

How to paint on canvas in javascript with alphamask?

开发者 https://www.devze.com 2022-12-17 07:19 出处:网络
I have a png image with white edges. I would like to make the edges transparent. Is there a way to specify a color to be not painted - like a color key or alphamask.

I have a png image with white edges. I would like to make the edges transparent.

Is there a way to specify a color to be not painted - like a color key or alphamask.

Are there any examples?

For example this image has white edges, and I would like to paint two of them close to eachother without the white.

alt text http://sketchup.google.com/3dwarehouse/download?mid=4a51b1bfaba开发者_Python百科674b2ca42c60e697162c&rtyp=st&ctyp=other&ts=1202486187000

How can I do that in javascript with canvas?


See globalCompositeOperation, or draw it in another canvas,remove white pixels (getImageData, if white, make it transparent) and putImageData of the new array to your canvas.


Convert the image to GIF format? GIF allows any single colour value to represent transparent pixels.

0

精彩评论

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

关注公众号