|
|
ASP世界
asp图像转数据流
作者:不详 来源:互联网
ASP 代码
- <%Function ReadGif(sStr)
- Dim i, iHex, sPath, oStream
- sPath = Server.MapPath(sStr)
- Set oStream = Server.CreateObject("Adodb.Stream")
- oStream.Type = 1
- oStream.Open
- oStream.LoadFromFile sPath
-
- For i = 1 To LenB(oStream.Read())
- oStream.Position = 0
- iHex = Hex(AscB(MidB(oStream.Read(), i, 1)))
- If Len(iHex) = 1 Then iHex = "0" & iHex
- ReadGif = ReadGif & iHex
- Next
-
- oStream.Close
- Set oStream = Nothing
- End Function
- %>
- <%=ReadGif("help.gif")%>
图像转数据流转ASP
ASP 代码
- <%
-
- WriteGif("上边的函数转的字符串全部放进来就可以了")
-
- Sub WriteGif(sStr)
- Dim aAry
- Response.Clear
- aAry = MySplit(sStr)
- Response.ContentType = "image/gif"
- For i = 0 To UBound(aAry)
- Response.BinaryWrite ChrB("&H" & aAry(i))
- Next
- End Sub
-
- Function MySplit(sStr)
- Dim sTmp
-
- For i = 1 To Len(sStr) Step 2
- sTmp = sTmp & Mid(sStr, i, 2) & ","
- Next
- If sTmp <> "" Then sTmp = Left(sTmp, Len(sTmp) - 1)
-
- MySplit = Split(sTmp, ",")
- End Function
- %>
|