我试图通过调用canvas.dataURL()方法将canvas转换为dataURL。它适用于尺寸为938x657的一些图像但是当我尝试具有大图像尺寸的相同功能时(例如3750x2625,7500x5250等),它返回“data:,”
代码:
var img = new Image();
img.src = app.getThemeLocalStorage("imgPath");
img.onload = function()
{
alert("width:"+img.width+" height:"+img.height);
$("#DummyCanvas").attr("width", img.width + "px");
$("#DummyCanvas").attr("height", img.height + "px");
var dummyCAN = document.getElementById("DummyCanvas");
var ctx = dummyCAN.getContext("2d");
ctx.drawImage(img, 0, 0);
var data = dummyCAN.toDataURL("image/png");
alert(data); //Alerts data url for image size 938x657 but blanks for 3750x2625
}
有任何建议/解决方案吗?