请教:一个关于从数据库中取2进制图片信息的问题!!!!请进来看看再说
qill 2003-06-09 08:08:37 用delphy把一个jpeg的图片以blob类型放进了oracle的数据库中
现在要用asp将他写出来
但是可能在存储的过程中加入了ole的头
现在用vb作了一个程序要把这个头去掉,取出其他的信息
主要的函数是这样写的,但是这个是去bmp的ole的头
不知道jpeg和bmp的是不是一样
哪位高手可以指点一下
Function DisplayBitmap(ByVal OleField As Variant)
Dim Arr() As Byte
Dim ObjHeader As OBJECTHEADER
Dim Buffer As String
Dim ObjectOffset As Long
Dim BitmapOffset As Long
Dim BitmapHeaderOffset As Integer
Dim ArrBmp() As Byte
Dim i As Long
'Resize the array, then fill it with
'the entire contents of the field
ReDim Arr(OleField.ActualSize)
Arr() = OleField.GetChunk(OleField.ActualSize)
'Copy the first 19 bytes into a variable
'of the OBJECTHEADER user defined type.
CopyMemory ObjHeader, Arr(0), 19
'Determine where the Access Header ends.
ObjectOffset = ObjHeader.HeaderSize + 1
'Grab enough bytes after the OLE header to get the bitmap header.
Buffer = ""
For i = ObjectOffset To ObjectOffset + 512
Buffer = Buffer & Chr(Arr(i))
Next i
'Make sure the class of the object is a Paint Brush object
If Mid(Buffer, 12, 6) = "PBrush" Then
BitmapHeaderOffset = InStr(Buffer, "BM")
If BitmapHeaderOffset > 0 Then
'Calculate the beginning of the bitmap
BitmapOffset = ObjectOffset + BitmapHeaderOffset - 1
'Move the bitmap into its own array
ReDim ArrBmp(UBound(Arr) - BitmapOffset)
CopyMemory ArrBmp(0), Arr(BitmapOffset), UBound(Arr) - BitmapOffset + 1
'Return the bitmap
DisplayBitmap = ArrBmp
End If
End If
End Function
谢谢