HTML5画布图像被裁剪

时间:2019-01-26 12:44:02

标签: javascript html5 html5-canvas

我正在尝试在图像内隐藏文本数据。我将画布创建为:

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

0 个答案:

没有答案