This Domain(Admin5.com) is for Sale:

从Access数据库恢复BMP图像并显示在WEB页面(microsoft)

时间:2007-12-23  来源:不详  作者:迈克DB

ClassLen As Integer
NameOffset As Integer
ClassOFfset As Integer
ObjectSize As PT
OleInfo As String * 256
End Type



Place the following code in the (general) (declarations) section of CLASS1.CLS:

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



Rename the Project by selecting the Project menu, and clicking on "Project1 Properties" and type your new
name in the "Project Name" field. This example assumes that you named the project "MyProject" and will
refer to that name in future steps.


Make the project Apartment Model Threaded by selecting the "Unattended Execution" check box. Click OK. dedecms.com


Rename the Class in the Property Pane. This example assumes that you named the class "MyClass" and refers
to that name in future steps.


Compile the DLL by clicking the File menu and selecting "Make MyProject.dll."


Create an ASP page named "bitmap." that contains the following code:

<%@ LANGUAGE="VBSCRIPT" %>
<%
'You need to set up a System DSN named 'NWind' that points to
'the Northwind.mdb database
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Open "DSN=NWind", "admin", ""
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set RS = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT Photo FROM Employees

看完这篇,您有何感觉呢?

文章评论

共有位Admini5网友发表了评论 查看完整内容

24小时热门信息