canvas.toDataURL(“image / png”)返回空白数据

时间:2015-08-25 13:35:15

标签: html5 canvas todataurl

我试图通过调用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
}

有任何建议/解决方案吗?

0 个答案:

没有答案