Comic books, cartoon strips, short stories,
games, cartoons, scifi, gimblians, misfits of fandom, just call me freedom,
matt gasser, david lugo
Optimal
with highspeed modem, but not required.
<%
Function RandomImage(ImagesFolderPath, ImageFileTypes, ImageDescription)
Dim CompleteImagesFolderPath
Dim FileSystemObject
Dim ImageFolder
Dim Files
Dim i
Dim ImageFiles
Dim File
Dim FileName
Dim FileExtension
Dim RandomNumber
CompleteImagesFolderPath = Server.MapPath(ImagesFolderPath)
Set FileSystemObject = Server.CreateObject("Scripting.FileSystemObject")
If Not FileSystemObject.FolderExists(CompleteImagesFolderPath) Then
RandomImage = "Error 0: Cannot find requested folder"
Set FileSystemObject = nothing
Exit Function
End If
Set ImageFolder = FileSystemObject.GetFolder(CompleteImagesFolderPath)
Set Files = ImageFolder.Files
i = 1
Set ImageFiles = Server.CreateObject("Scripting.Dictionary")
For Each File in Files
FileName = File.Name
FileExtension = Right(FileName, Len(FileName) - (InStrRev(FileName, ".")))
If InStr(1,ImageFileTypes,FileExtension,vbTextCompare) > 0 then
ImageFiles.Add i, FileName
i = i + 1
End If
Next
Set ImageFolder = nothing
Set Files = nothing
Set FileSystemObject = nothing
Randomize
If ImageFiles.Count = 0 Then
RandomImage = "Error 1: Requested folder does not contain any image files"
Exit Function
End If
RandomNumber = Int((ImageFiles.Count) * Rnd + 1)
HW = ReadImg(ImagesFolderPath & ImageFiles.Item(RandomNumber))
RandomImage = ""
Set ImageFiles = nothing
End Function
Dim HW
Function AscAt(s, n)
AscAt = Asc(Mid(s, n, 1))
End Function
Function HexAt(s, n)
HexAt = Hex(AscAt(s, n))
End Function
Function isJPG(dreamPath)
If inStr(uCase(dreamPath), ".JPG") <> 0 Then
isJPG = true
Else
isJPG = false
End If
End Function
Function isPNG(dreamPath)
If inStr(uCase(dreamPath), ".PNG") <> 0 Then
isPNG = true
Else
isPNG = false
End If
End Function
Function isGIF(dreamPath)
If inStr(uCase(dreamPath), ".GIF") <> 0 Then
isGIF = true
Else
isGIF = false
End If
End Function
Function isBMP(dreamPath)
If inStr(uCase(dreamPath), ".BMP") <> 0 Then
isBMP = true
Else
isBMP = false
End If
End Function
Function isWMF(dreamPath)
If inStr(uCase(dreamPath), ".WMF") <> 0 Then
isWMF = true
Else
isWMF = false
End If
End Function
Function isWebImg(f)
If isGIF(f) Or isJPG(f) Or isPNG(f) Or isBMP(f) Or isWMF(f) Then
isWebImg = true
Else
isWebImg = true
End If
End Function
Function ReadImg(dreamPath)
If isGIF(dreamPath) Then
ReadImg = ReadGIF(dreamPath)
Else
If isJPG(dreamPath) Then
ReadImg = ReadJPG(dreamPath)
Else
If isPNG(dreamPath) Then
ReadImg = ReadPNG(dreamPath)
Else
If isBMP(dreamPath) Then
ReadImg = ReadPNG(dreamPath)
Else
If isWMF(dreamPath) Then
ReadImg = ReadWMF(dreamPath)
Else
ReadImg = Array(0,0)
End If
End If
End If
End If
End If
End Function
Function ReadJPG(dreamPath)
Dim fso, ts, s, HW, nbytes
HW = Array("","")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath("/" & dreamPath), 1)
s = Right(ts.Read(167), 4)
HW(0) = HexToDec(HexAt(s,3) & HexAt(s,4))
HW(1) = HexToDec(HexAt(s,1) & HexAt(s,2))
ts.Close
ReadJPG = HW
End Function
Function ReadPNG(dreamPath)
Dim fso, ts, s, HW, nbytes
HW = Array("","")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath("/" & dreamPath), 1)
s = Right(ts.Read(24), 8)
HW(0) = HexToDec(HexAt(s,3) & HexAt(s,4))
HW(1) = HexToDec(HexAt(s,7) & HexAt(s,8))
ts.Close
ReadPNG = HW
End Function
Function ReadGIF(dreamPath)
Dim fso, ts, s, HW, nbytes
HW = Array("","")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath("/" & dreamPath), 1)
s = Right(ts.Read(10), 4)
HW(0) = HexToDec(HexAt(s,2) & HexAt(s,1))
HW(1) = HexToDec(HexAt(s,4) & HexAt(s,3))
ts.Close
ReadGIF = HW
End Function
Function ReadWMF(dreamPath)
Dim fso, ts, s, HW, nbytes
HW = Array("","")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath("/" & dreamPath), 1)
s = Right(ts.Read(14), 4)
HW(0) = HexToDec(HexAt(s,2) & HexAt(s,1))
HW(1) = HexToDec(HexAt(s,4) & HexAt(s,3))
ts.Close
ReadWMF = HW
End Function
Function ReadBMP(dreamPath)
Dim fso, ts, s, HW, nbytes
HW = Array("","")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath("/" & dreamPath), 1)
s = Right(ts.Read(24), 8)
HW(0) = HexToDec(HexAt(s,4) & HexAt(s,3))
HW(1) = HexToDec(HexAt(s,8) & HexAt(s,7))
ts.Close
ReadBMP = HW
End Function
Function isDigit(c)
If inStr("0123456789", c) <> 0 Then
isDigit = true
Else
isDigit = false
End If
End Function
Function isHex(c)
If inStr("0123456789ABCDEFabcdef", c) <> 0 Then
isHex = true
Else
ishex = false
End If
End Function
Function HexToDec(cadhex)
Dim n, i, ch, decimal
decimal = 0
n = Len(cadhex)
For i=1 To n
ch = Mid(cadhex, i, 1)
If isHex(ch) Then
decimal = decimal * 16
If isDigit(c) Then
decimal = decimal + ch
Else
decimal = decimal + Asc(uCase(ch)) - Asc("A")
End If
Else
HexToDec = -1
End If
Next
HexToDec = decimal
End Function
%>