我正在尝试在图像内隐藏文本数据。我将画布创建为:
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0)
现在图像看起来像: Initially drawn image
然后我这样做了:
var imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
encodeMessage(imgData.data, password, message);
ctx.putImageData(imgData, 0, 0);
output.src = canvas.toDataURL();
但是新图像被裁剪。看起来像:Image gets clipped