javascript - Method DrawImage in Firefox does not work correctly with green pixels? -


for example, when paint on canvas image of 1 pixel, , attempt see painted on canvas, different color? in code below, first image pixel has color rgba (0,255,0,255), when try bring him red component, 1 instead of 0, why?

<html>   <head>     <meta charset="utf-8">   </head>   <body>     <div class="bg" align="center" id="head">       <canvas id="canvas" width="1" height="1"></canvas>     </div>     <div align="center">       <h1 id="result">loading...</h1>       <i><pre id="nav">loading...</pre></i>       <img id="img" src="data:image/png;base64,ivborw0kggoaaaansuheugaaaaeaaaabcayaaaaffcsjaaaaaxnsr0iars4c6qaaaarnqu1baacxjwv8yquaaaajcehzcwaadsqaaa7eazurdhsaaaansurbvbhxy2d4z/afaaqbaf9eluglaaaaaelftksuqmcc" height="10%" border="1" />     </div>     <script type='text/javascript'>       function foo()       {         var img=document.getelementbyid('img');         var w=img.naturalwidth;         var h=img.naturalheight;         canvas.getcontext('2d').drawimage(img,0,0,w,h);         var data=canvas.getcontext('2d').getimagedata(0,0,w,h).data;         document.getelementbyid('result').innerhtml = "data[0] == "+data[0];         document.getelementbyid('nav').innerhtml = navigator.useragent;       };       settimeout(foo,100);     </script>   </body> </html> 

that's get:

data[0] == 1 mozilla/5.0 (windows nt 6.1; wow64; rv:23.0) gecko/20100101 firefox/23.0 

this going dependent on png using... though it's data:image, browsers can , handle color profiles differently.

i made fiddle : http://jsfiddle.net/yhu8n/2/

this doesn't use png, instead draws green (0,255,0) rect png doing. difference know doesn't contain color profile of type.

any reason using green png? call draw green rect far faster load.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -