当前位置: 代码迷 >> JavaScript >> canvas 改变图片色彩
  详细解决方案

canvas 改变图片色彩

热度:275   发布时间:2013-07-01 12:33:04.0
canvas 改变图片颜色
 
<!DOCTYPE html>
<!--    to moving elements in a straight line   -->
    <html>
        <head>
            <meta charset='utf-8'/>
            <script type="text/javascript"> 
                
                
                window.addEventListener('load',canvasApp, false);
                
                function canvasApp(args) {
                    var canvas = document.getElementById("MyCanvas");
                    var context = canvas.getContext("2d");
                    
                    var logoL = new Image();
                        logoL.src= "../img/csrLeft.png";
                    var widthL = 88;
                    var logoR = new Image();
                        logoR.src = "../img/csrRight.png";
                    var widthR = 286;
                    var height = 31;
                    context.drawImage(logoL,0,0);
                    
                    var dataL = context.getImageData(0,0,widthL,height);
                    
                    for (var i=0; i<dataL.data.length; i+=4 ) {
                        
                        dataL.data[i] = 29;
                        dataL.data[i+1] = 58;