从字符串中提取图片数据 [英] Extract Picture Data from a String
本文介绍了从字符串中提取图片数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的,
提前致谢.任何人都可以帮助解决以下问题.
我做了一个套接字应用程序,它从车辆跟踪unit.one
示例接收数据,如下所示:
Dears,
Thanks in advance. Can anybody help to solve my problem which is described below.
I did a socket application which is receiving data from a vehicle tracking unit.one
example as follows:
Example- %%D1,100,0,0004[data...][0d0a]
Head - %%D1
Amount of data package -100
The data package No. - 0
Data Length -1024 (0004 (low bit in front, high bit in back) 0004= 0x0400=1024;)
data- Original Picture data -1024(maximum)
Tail -0x0d0a
Data in hex
从上面的示例中,我想提取图片数据并将其存储到SQL表中. SQL表columname
是映像,datatype
也是映像.之后,我想将此图像列显示到aspx页面.
尽快寻求帮助.
From the above example, I want to extract picture data and need to store into the SQL table. SQL table columname
is image and datatype
is also image. After that, I want to display this image column to an aspx page.
expecting help asap.
推荐答案
如果我没看错,则图像数据为十六进制格式,对吗?因此我们可以将数据放入字节数组中,然后将其保存到数据库中.
提取数据并将其保存到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 abytearray
, 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 aMemoryStream
, 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
这篇关于从字符串中提取图片数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文