2012-11-23 110 views

回答

2

它會去像這樣的純javascript:

var c=document.getElementById("myCanvas"); 
var ctx=c.getContext("2d");  
var imgData = ctx.createImageData(100,100); 

var buffer = new ArrayBuffer(4*100*100); 
var ubuf = new Uint8Array(buffer); 
for (var i=0;i < ubuf.length; i+=4) { 
    imgData.data[i] = ubuf[i]; //red 
    imgData.data[i+1] = ubuf[i+1]; //green 
    imgData.data[i+2] = ubuf[i+2]; //blue 
    imgData.data[i+3] = ubuf[i+3]; //alpha 
} 

ctx.putImageData(imgData,0,0); 

爲此在GWT,你需要在JSNI method

來包裝這個