繁体   English   中英

将画布作为图像保存到ASP.net中的服务器

[英]Save a canvas as an image to the server in ASP.net

我有一个带有谷歌地图的页面和一些div中的一些数据,我需要用户点击“Grab Screenshot”按钮,这应该保存用户页面的屏幕截图并将其保存到服务器。

我尝试了Html2Canvas,但它不允许我将canvas转换为dataurl,即在我的javascript函数中,我使用了这个:

    function GenerateImage()
    {
    html2canvas($('#mainDiv'), {
        onrendered: function(canvas) {
            //this appends the canvas(screenshot) to the page, this is working fine
               document.body.appendChild(canvas);
            //this is not working, 
            //Error: SecurityError: The operation is insecure.
            var image = canvas.toDataURL('image/png');
            image.crossOrigin = 'anonymous'; 
            var imgdata = image.replace(/^data:image\/(png|jpg);base64,/, '');

            $.ajax({
                url: '******',
                data: {
                       imgdata:imgdata
                       },
                type: 'post',
                success: function (response) {   
                console.log('Success');
                }
            });
    }
    });
    }

我做了研究,我发现它是一些CORS问题,但我无法找到解决方案。

所以,我想知道我是否可以使用ASP.net做截图,这可能吗? 提前致谢。

我能够使用代理成功地完成它。 我在地图上的其他网站上遇到了自定义标记图标的问题。 这导致帆布污染。 我将图像移动到我的网站并更改了路径,“污染的画布可能无法导出”错误消失了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM