tags:

views:

228

answers:

2

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

How can I do that in javascript with canvas?

A: 

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

Mick Sharpe
Not an option at this task.
zproxy
+1  A: 

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.

Paul Rouget
Do you have a code example online for it? :)
zproxy
I've written some code doing something like that: See: http://people.mozilla.com/~prouget/demos/fennec/imgManipulation/And: http://people.mozilla.com/~prouget/demos/green/green.xhtml
Paul Rouget