1
我使用FabricJS v1.5.0,並且在畫布上逐像素操作時出現問題。使用FabricJS進行像素操作
this.canvas = new this.fabric.Canvas('canvas');
let imageData = this.canvas.contextContainer.getImageData(0, 0, this.canvas.getWidth(), this.canvas.getHeight());
//here a changed imageData
this.canvas.contextContainer.putImageData(imageData, 0, 0);
//data seted in canvas.
let imageAdd = new this.fabric.Image(image, {
left: 100,
top: 100,
width: 100,
height: 100
});
this.canvas.add(imageAdd).setActiveObject(imageAdd);
//in this moment, the canvas don't have more the imageData setted
爲什麼要添加圖像清晰imageData?我需要將FabricJS對象中的imageData轉換爲在canvas中添加?