<%
': :::::::::::::::::::::::::: ::::::::::::::::::
': :::::::::::::::::::::::::: ::::::::::::::::::
'::: BMP, GIF, JPG and PNG :::
':::: Original: junyd ::::::::::
'::::: ::::::::::::::::::::::::::: :::
'::: :::
':: This Dongdong can get this file from BMP, GIF, JPG and PNG picture :::
': :::::::::::::::::::::::::: ::::::::::::::::::
Function getBytes (flnm, offset, bytes)
DIM OBJFSO
DIM Objftemp
DIM ObjTextStream
Dim lngsize
ON Error ResMe next
Set objfso = creteObject ("scripting.filesystemobject")
'First, we get FileSize
Set objftemp = objfso.getfile (flnm)
LNGSIZE = Objftemp.size
Set objftemp = Nothing
FsoForReading = 1
Set objTextStream = objfso.opentextfile (flnm, fsoforreading)
IF offset> 0 THEN
Strbuff = ObjtextStream.read (Offset - 1)
END IF
iftes = -1 Then 'get all!
GetBytes = ObjtextStream.Read (LNGSIZE) 'Readall
Else
GetBytes = ObjTextStream.read (bytes)
END IF
ObjtextStream.close
Set objtextStream = Nothing
Set objfso = Nothing
END FUNCTION
': :::::::::::::::::::::::::: :::::::::::::: ': ::: :::' :: ::: ':::: (Small endian and big endian) ::: '::::::::::::::::::: :::::::::::::::::::::::::::::::::::::th " 1)) ((ASC (Right (straTemp, 1)) * 256))))))))) End FunctionFunction LNGCONVERT2 (STRTEMP) LNGCONVERT2 = ClNG (ASC (Right (strTemp, 1)) ((ASC (strave (straTemp, 1) )) * 256))) End function ': ::::::::::::::::::::::: ::::::::::::::::::::::::::::: '::::::' ::: This function makes most real work.
It is willing to try ::: '::: Read any file :::' ::: If it is an image of a chart, identification. ::: '::: :::' :::pased: ::: '::: File to read :::' ::: => width of image ::: => => height of image ::: '::: Depth => color depth (in Number of Colors) ::: '::: StrimageType => Type of Image (EG GIF, BMP, etc.) :::' ::: ::: ':::::::::' ::::::::: ::::: :::::::::::::::::::::: :::::: function gfxSpex (flnm, width, height, depth, strImageType) dim strPNG dim strGIFdim strBMPdim strTypestrType = "" strImageType = "(unknown)" gfxSpex = FalsestrPNG = chr (137) & chr (80) & chr (78) strgif = "gif" strbmp = chr (66) & chr (77) strtype = getBytes (flnm, 0, 3) if strtype = strgif kilns gifstrimageType = "gif" width = LNGCONVERT (GetBytes (FLNM, 7) 2)) Height = LNGCONVERT (Gettes (FLNM, 9, 2)) DEPTH = 2 ^ ((ASC (Gettes (FLNM, 11, 1)) and 7) 1) gfxspex = trueelseif left (strueelseif left (strType, 2) = Strbmphen 'is bmpstrimageType = "bmp" width = lcomconvert (GetBytes (FLNM, 19, 2)) HEIGHT = LNGCONVERT (GetBytes (FLNM, 23, 2)) Depth = 2 ^ (ASC (Gettes (f LNM, 29, 1))) GFXSPEX = Trueelseif Strtype = strpng the 'is pngstrimageType = "PNG" width = LNGCONVERT2 (GetBytes (FLNM, 19, 2)) Height = LNGCONVERT2 (GetBytes (FLNM, 23, 2)) DEPTH = Gettes (FLNM, 25, 2) SELECT CASE ASC (Right (depth, 1)) Case 0Depth = 2 ^ (ASC (Left (depth, 1))) GFXSPEX = truecase 2Depth = 2 ^ (ASC (LEFT (Depth, 1 )) * 3) gfxspex = truecase 3Depth = 2 ^ (ASC (defrm (defth, 1))) '8GFXSPEX = truecase 4Depth = 2 ^ (ASC (LEFT (DEPTH, 1)) * 2) GFXSPEX =
Truecase 6Depth = 2 ^ (asc (left (Depth, 1)) * 4) gfxSpex = Truecase elseDepth = -1end selectelsestrBuff = GetBytes (flnm, 0, -1) 'Get all bytes from filelngSize = len (strBuff) flgFound = 0strTarget = chr (255) & chr (216) & chr (255) flgFound = instr (strBuff, strTarget) if flgFound = 0 thenexit functionend ifstrImageType = "JPG" lngPos = flgFound 2ExitLoop = falsedo while ExitLoop = False and lngPos Do WHILE ASC (MID (Strbuff, LNGPOS, 1)) = 255 and LNGPOS ': :::::::::::::::::::::::::: :::::::::::::::::::::::::::::::: :::::: :::::::::::::::::: "For for Test, we put the file in C: / on set objfso = createObject ("scripting.filesystemObject") set objf = objfso.getfolder ("c: /") set objfc = objf.filesResponse.write "