'循环找到 SOI marker 的位置
for i = 1 to size
if AscB(MidB(field, i, 1)) = &HFF and AscB(MidB(field, i + 1, 1)) = &HD8 then
exit for
end if
next
'忽略前面的无用信息, 从 SOI marker 开始输出真正的图片信息
for j = i to size
response.BinaryWrite MidB(field, j, 1)
next
end function
%>
<%
'-------- 主程序开始 -------------------
dim conn
set conn = Server.CreateObject("ADODB.Connection")
conn.open("Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=123;Data Source=MARK")
sql = "select * from xinxi_mishuchu"
set rs = conn.execute(sql)
'声明输出类型, 清空输出缓冲区
response.buffer = true
response.clear
response.ContentType = "image/jpeg"
'调用函数输出图片
ShowJpegField(rs("picture1"))
'打完收功!
rs.close : set rs = nothing
conn.close : set conn = nothing
%>
如果是其他格式的图片, 如 bmp, gif 等, 输出方法类似, 只不过是 SOI marker 不同而已。
由于作者水平有限, 错误之处在所难免,欢迎大家批评指正。
|