图片存储问题
我写了一个过程专门存储及读取IMAGE字段的信息,过程如下:
'存储图片信息
Public Function SaveImageToField(ByVal strImageFile As String, fldCol As Field) As Boolean
On Error GoTo ErrHand
Dim Images() As Byte
Open strImageFile For Binary As #1
ReDim Images(LOF(1))
Get #1, 1, Images()
Close #1
fldCol.AppendChunk Images
SaveImageToField = True
Exit Function
ErrHand:
MsgBox Err.Description, vbInformation, "提示 "
End Function
'提取图片信息
Public Function GetImageForField(fldCol As Field) As IPictureDisp
On Error GoTo ErrHand
Dim objPic As IPictureDisp
Dim Images() As Byte
If IsNull(fldCol.Value) Then Exit Function
ReDim Images(fldCol.ActualSize - 1)
Images() = fldCol.GetChunk(fldCol.ActualSize)
If objFSO.FileExists(App.Path & "\tmg.dat") Then objFSO.DeleteFile App.Path & "\tmg.dat"
Open App.Path & "\tmg.dat" For Binary As #1
Put #1, , Images()
Close #1
Set objPic = LoadPicture(App.Path & "\tmg.dat")
objFSO.DeleteFile App.Path & "\tmg.dat"
Set GetImageForField = objPic
Exit Function
ErrHand:
MsgBox Err.Description, vbInformation, "提示"
End Function
我觉得这两个过程执行效率不是很好,还望哪位大侠有什么高招多赐教一些,感谢!
在新的一年里,祝大家心想事成,万事大吉!