// 参数参考:https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage
ctx.globalAlpha = 1; // 水印透明度
ctx.beginPath();
ctx.drawImage(water_img, 0, 0, water_width, water_height, x, y, water_width, water_height); // 将水印图像绘制到canvas上
ctx.closePath();
ctx.save();
}
var imagedata = ctx.getImageData(0, 0, canvas_width, canvas_height);
var data = imagedata.data;
// 判断与 [0,0] 值相同的并且连续的像素为背景
//xn.image_background_opacity(data, canvas_width, canvas_height);
// 将修改后的代码复制回画布中
ctx.putImageData(imagedata, 0, 0);
//filetype = 'png';
if(filetype == 'jpg') filetype = 'jpeg';
var s = canvas.toDataURL('image/'+filetype, qulity);
if(callback) callback(0, {width: width, height: height, data: s});
};