如何使用Vb.Net/C#将画布上绘制的图像保存到Mssql数据库中 [英] How Do I Save An Image Drawn On A Canvas Into A Mssql Database Using Vb.Net/C#

查看:134
本文介绍了如何使用Vb.Net/C#将画布上绘制的图像保存到Mssql数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我创建了一个用户可以在其上绘制的画布我想知道如何将绘制的图像保存到画布上一旦用户点击了保存按钮?

Hi

I have created a canvas on which a user can draw on i would like to know how would i be able to save the image drawn onto the canvas once the user clicks the save button?

推荐答案

我不确定为什么你需要这个场景但你可以使用以下步骤来实现它。



我正在考虑你有SVG可用。



您可以考虑将SVG转换为二进制(图像)并将该blob保存到数据库中。



I am not sure why you have that scenario required but you can achieve it using below steps.

I am considering you have SVG available.

You can considering converting SVG to Binary (Image) and save that blob into database.

var html = d3.select("svg")
      .attr("version", 1.1)
      .attr("xmlns", "http://www.w3.org/2000/svg")
      .node().parentNode.innerHTML;





在上面的代码中,你将获得html作为表示Image的二进制值字符串。



现在你可以将这个二进制字符串转换为二进制数组或您可以将其存储在数据库中。



如果您只是为了在服务器上保存图像,那么我建议生成图像并保存具有唯一GUID名称的服务器并将该信息保存在数据库中。



谢谢

Rushi



In above code you will get html as string of binary values which represents that Image.

Now you can convert this Binary String to Binary Array or you can store it as it is in database.

If you are achieving just to save Image on server, then I would suggest that generate an Image and save on server with unique GUID Name and save that information in database.

Thanks
Rushi


这篇关于如何使用Vb.Net/C#将画布上绘制的图像保存到Mssql数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆