二进制操作文件Javascript

时间:2018-01-20 11:28:31

标签: javascript binary

我尝试操纵二进制文件,ex我想改变简单bmp文件的颜色。

这是我的jsfiddle https://jsfiddle.net/51tLpwy8/

这是要加载https://ufile.io/sx9o5

的bmp文件

我的代码:

<body onload='
// Reset the textarea value
m.value="00";
// Init the top cell content
for(i=0;i<16;i++)
  t.innerHTML+=(0+i.toString(16)).slice(-2)+" ";
'>
<input onchange='
// When a file is selected, reset h
h="";
// Read the uploaded file as an ArrayBuffer
(f=new FileReader).readAsArrayBuffer(w.files[0]);
f.onload=function(){

  // Loop on the file bytes
  for(i in u=new Uint8Array(f.result))

    // Convert each byte in hexadecimal
    h+=(0+u[i].toString(16)).slice(-2);

console.log(h);
  // Write h in the hex textarea
  m.value=h;

  // Trigger oninput on hex textarea
  m.oninput()

}'

我想要什么 - 改变前。颜色为黄色至绿色,具有一定功能。 谢谢你的帮助!

0 个答案:

没有答案
相关问题