且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从字符串中提取图片数据

更新时间:2022-06-23 05:12:19

如果我没看错,则图像数据为十六进制格式,对吗?因此我们可以将数据放入字节数组中,然后将其保存到数据库中.

提取数据并将其保存到bytearray后,其余的操作将很容易.这是一个很好的例子:
在C#中将十六进制字符串与字节数组进行转换 [ http://msdn.microsoft.com/zh-我们/library/e55f3s5k.aspx [ ^ ].

然后将其存储在数据库中,请参见:
http://www.codersource.net/asp-net/ado-net/reading-and-writing-images-from-sql-server.aspx [
If I got that right, image data is in Hex format, right? So we can put the data in a bytearray, and then save it to database.

Once you extracted data and saved it to a bytearray, the rest will be easy. Here is a good example of how to do that:
Converting Hexadecimal String to/from Byte Array in C#[^].

You need to create a MemoryStream, see this: http://msdn.microsoft.com/en-us/library/e55f3s5k.aspx[^].

Then store it in database, see this:
http://www.codersource.net/asp-net/ado-net/reading-and-writing-images-from-sql-server.aspx[^].

--------------------

Regards

H.Maadani