Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
SQL图片列是image类型,存放照片二进制内容“0xFFD8FFE000104A46494600010100000100010000FFDB0043000302020302020303030304030304050805050404050A070706080C0A0C0C0B0A0B0B0D0E12100D0E110E0B0B1016101113141515150C0F171816141812141514FFDB00430103040405040509050509140D0B0D14141414141414141414141414141414141414”
发现这个查询是很慢的。我把照片存放二进制为text类型时,查询是很快的。但是如何把text转换成byte类型的。
Dim imageByte() As Byte = Tables("卸船货损管理_Table1").Current("照片") ‘原来照片列是image类型的,现改成了text类型了
Dim ms As New IO.MemoryStream(imageByte) '将字节数组转换为二进制流
Dim image As Image = Image.FromStream(ms) '将二进制流转换为图片
e.Form.Controls("Picturebox1").Image = image
请问以上代码应如何实现呢?谢谢指教。
请教下,是否把图片以二进制存储在表中image类型列中,在查询此表数据时反映是否很慢?
看2楼。
不太明白。
但这样不行。
dim s as stirng = Tables("卸船货损管理_Table1").Current("照片") '是text类型的二进制。
Dim imageByte() As Byte = Convert.FromBase64String(s)
Dim ms As New IO.MemoryStream(imageByte) '将字节数组转换为二进制流
Dim image As Image = Image.FromStream(ms) '将二进制流转换为图片
e.Form.Controls("Picturebox1").Image = image
提示字符组无效长度。
我这个通过测试的:
Dim fs As New IO.FileStream("c:\001.gif" , IO.FileMode.Open , IO.FileAccess.Read) '用文件流打开图片
Dim br As New IO.BinaryReader(fs)
Dim bt1 As Byte() = br.ReadBytes(fs.Length)
Dim s As String = Convert.ToBase64String (bt1)
Dim bt2 As Byte() = Convert.FromBase64String(s)
Dim ms As New IO.MemoryStream(bt2) '将字节数组转换为二进制流
Dim image As Image = Image.FromStream(ms) '将二进制流转换为图片
e.Form.Controls("PictureBox1").Image = image '显示图片
老大,没有明白我的意思。
Dim imageByte() As Byte = Tables("卸船货损管理_Table1").Current('照片')
’这个列是image类型,已存放的是二进制方式。我把这个二进制的内容保存到一个*。txt文件中。
如何实现等效的代码?谢谢!!
Dim bt1() as Byte= Tables("卸船货损管理_Table1").Current('照片')
Filesys.WriteAlltext(文件名,Convert.ToBase64String (bt1))
Dim bt2 As Byte() = Convert.FromBase64String(Filesys.ReadAllText(文件名))