Dim con As New ADODBConnection
Dim RS As New ADODBRecordset
Dim ChunkSize As Long, Chunks As Long, Chunk() As Byte
Dim i As Integer, j As Integer, MediaTemp As String
ChunkSize = 10000
For i = 1 To List1ListCount - 1
If Len(Dir(dbPath + "img\" + List1List(i), vbDirectory)) = 0 Then MkDir (dbPath + "img\" + List1List(i))
conConnectionString = "Provider=MicrosoftJetOLEDB40;Data Source=" + dbPath + List1List(i) + "mdb;Persist Security Info=False"
conOpen
RSSource = "select from [Images] order by ID"
RSActiveConnection = con
RSOpen
If RSEOF Then
RSClose
Exit Sub
End If
Do While Not RSEOF
'第二步,读出长二进制数据即数据,把它转换成文件, *** 作过程如下
MediaTemp = dbPath + "img\" + List1List(i) + "\" + RSFields
DataFile = 1
Open MediaTemp For Binary Access Write As DataFile
lngTotalSize = RS!PICActualSize
Chunks = lngTotalSize / ChunkSize
Fragment = lngTotalSize Mod ChunkSize
ReDim Chunk(Fragment)
Chunk() = RS!PICGetChunk(Fragment)
Put DataFile, , Chunk()
For j = 1 To Chunks
ReDim Chunk(ChunkSize)
Chunk() = RS!PICGetChunk(ChunkSize)
Put DataFile, , Chunk()
Next j
Close DataFile
RSMoveNext
Loop
'第三步,关闭数据库,这样就可以显示所要的了。
RSClose
conClose
Next i
MsgBox "OK!"
binasciihexlify估计能满足你的要求。不过不建议把二进制数据用编解码来处理,因为编解码只是文本采用了不同的编码方案。而图像这些二进制有自己的含义,文本编解码方案不应该用在这些二进制文件上。s就是你的数据,你也别想看懂,除非你知道jpg格式。
以上就是关于vb6.0 怎样用image控件读取ACCESS中以二进制保存的图片全部的内容,包括:vb6.0 怎样用image控件读取ACCESS中以二进制保存的图片、Python中读取二进制图片(例如 a.jpg)有关解码编码的问题、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)