Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/10/2014, 05:29
brooo
 
Fecha de Ingreso: octubre-2014
Mensajes: 2
Antigüedad: 9 años, 6 meses
Puntos: 0
Mensaje Canvas negativo i blanco y negro

Hola necesito una funcion que dado un canvas ya dibujado me cree el negativo y el blanco y negro. de momento tengo este codigo pero no me funciona si me pudieran ayudar me aharian un favor.


Código:
function negatiu(){
alert("negatiu");	
 //if (document.getElementById('negatiu').checked) {
 	var canvas = document.getElementById('CanvaXfunction');
	var ctx = canvas.getContext('2d');	
	var dadesimatge= ctx.getImageData(0,0,canvas.width,canvas.height);
	var	dades=dadesimatge.data;
	for(var i=0; i<dades.lenght;i+=4){
		dades[i]=255-dades[i];
		dades[i+1]=255-dades[i+2];
		dades[i+2]=255-dades[i+2];
		
	}
	ctx.putImageData(dadesimatge,0,0);
//	}
  alert("bye");  
	
}