[未利用地]利用FSO取得BMP,JPG,PNG,GIF文件信息大小,宽、高等

更新时间:2019-09-05 来源:热门资讯 点击:

【www.hzclsc.cn--热门资讯】

Filespec of file to read :::

 "::: offset => Offset at which to start reading :::

 "::: bytes => How many bytes to read :::

 "::: :::

 ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 function GetBytes(flnm, offset, bytes)

 Dim objFSO

 Dim objFTemp

 Dim objTextStream

 Dim lngSize

 on error resume next

 Set objFSO = CreateObject("Scripting.FileSystemObject")

 

 " First, we get the 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

 if bytes = -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



 ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 "::: :::

 "::: Functions to convert two bytes to a numeric value (long) :::

 "::: (both little-endian and big-endian) :::

 "::: :::

 ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 function lngConvert(strTemp)

 lngConvert = clng(asc(left(strTemp, 1)) + ((asc(right(strTemp, 1)) * 256)))

 end function

 function lngConvert2(strTemp)

 lngConvert2 = clng(asc(right(strTemp, 1)) + ((asc(left(strTemp, 1)) * 256)))

 end function

 

 ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 "::: :::

 "::: This function does most of the real work. It will attempt :::

 "::: to read any file, regardless of the extension, and will :::

 "::: identify if it is a graphical image. :::

 "::: :::

 "::: Passed: :::

 "::: flnm => Filespec of file to read :::

 "::: width => width of image :::

 "::: height => height of image :::

 "::: depth => color depth (in number of colors) :::

 "::: strImageType=> type of image (e.g. GIF, BMP, etc.) :::

 "::: :::

 ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 function gfxSpex(flnm, width, height, depth, strImageType)

 dim strPNG

 dim strGIF

 dim strBMP

 dim strType

 strType = ""

 strImageType = "(unknown)"

 gfxSpex = False

 strPNG = chr(137) chr(80) chr(78)

 strGIF = "GIF"

 strBMP = chr(66) chr(77)

 strType = GetBytes(flnm, 0, 3)

 if strType = strGIF then " is GIF

 strImageType = "GIF"

 Width = lngConvert(GetBytes(flnm, 7, 2))

 Height = lngConvert(GetBytes(flnm, 9, 2))

 Depth = 2 ^ ((asc(GetBytes(flnm, 11, 1)) and 7) + 1)

 gfxSpex = True

 elseif left(strType, 2) = strBMP then " is BMP

 strImageType = "BMP"

 Width = lngConvert(GetBytes(flnm, 19, 2))

 Height = lngConvert(GetBytes(flnm, 23, 2))

 Depth = 2 ^ (asc(GetBytes(flnm, 29, 1)))

 gfxSpex = True

 elseif strType = strPNG then " Is PNG

 strImageType = "PNG"

 Width = lngConvert2(GetBytes(flnm, 19, 2))

 Height = lngConvert2(GetBytes(flnm, 23, 2))

 Depth = getBytes(flnm, 25, 2)

 select case asc(right(Depth,1))

 case 0

 Depth = 2 ^ (asc(left(Depth, 1)))

 gfxSpex = True

 case 2

 Depth = 2 ^ (asc(left(Depth, 1)) * 3)

 gfxSpex = True

 case 3

 Depth = 2 ^ (asc(left(Depth, 1))) "8

 gfxSpex = True

 case 4

 Depth = 2 ^ (asc(left(Depth, 1)) * 2)

 gfxSpex = True

 case 6

 Depth = 2 ^ (asc(left(Depth, 1)) * 4)

 gfxSpex = True

 case else

 Depth = -1

 end select



 else

 strBuff = GetBytes(flnm, 0, -1) " Get all bytes from file

 lngSize = len(strBuff)

 flgFound = 0

 strTarget = chr(255) chr(216) chr(255)

 flgFound = instr(strBuff, strTarget)

 if flgFound = 0 then

 exit function

 end if

 strImageType = "JPG"

 lngPos = flgFound + 2

 ExitLoop = false

 do while ExitLoop = False and lngPos 195 then

 lngMarkerSize = lngConvert2(mid(strBuff, lngPos + 1, 2))

 lngPos = lngPos + lngMarkerSize + 1

 else

 ExitLoop = True

 end if

 loop

 "

 if ExitLoop = False then

 Width = -1

 Height = -1

 Depth = -1

 else

 Height = lngConvert2(mid(strBuff, lngPos + 4, 2))

 Width = lngConvert2(mid(strBuff, lngPos + 6, 2))

 Depth = 2 ^ (asc(mid(strBuff, lngPos + 8, 1)) * 8)

 gfxSpex = True

 end if

 

 end if

 end function



 ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 "::: Test Harness :::

 ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 

 " To test, we"ll just try to show all files with a .GIF extension in the root of C:

 Set objFSO = CreateObject("Scripting.FileSystemObject")

 Set objF = objFSO.GetFolder("c:\")

 Set objFC = objF.Files

 response.write ""

 For Each f1 in objFC

 if instr(ucase(f1.Name), ".GIF") then

 response.write "" f1.name "" f1.DateCreated "" f1.Size ""

 if gfxSpex(f1.Path, w, h, c, strType) = true then

 response.write w " x " h " " c " colors"

 else

 response.write " "

 end if

 response.write ""

 end if

 Next

 response.write ""

 set objFC = nothing

 set objF = nothing

 set objFSO = nothing



%>














本文来源:http://www.hzclsc.cn/news/26479.html

为您推荐

dnf鬼泣新buff换装|dnf鬼泣BUFF换装如何搭配 dnf起源版鬼泣BUFF换装搭配攻略

您的位置:首页 → 网游资讯 → dnf资讯 → dnf鬼泣BUFF换装如何搭配 dnf起源版鬼泣BUFF换装搭配攻略 dnf鬼泣BUFF换装如何搭配 dnf起源版鬼泣BUFF换装搭配攻略时间:201dnf资讯

2021-02-25 18:54:41   dnf鬼泣buff换装95   地下城鬼泣buff换装  

dnf流年鬼泣装备_dnf鬼泣起源版本装备搭配推荐 dnf黑暗君主起源版本加点攻略

2月1日DNF起源版本正式更新了,这次更新全职业平衡性将进行调整,所以这个版本DNF黑暗君主起源版本怎么加点?DNF黑暗君主起源版本用什么装备好?下面小编为大家爱带来了DNF黑暗君主起源版本加点攻略dnf资讯

2021-02-25 18:54:41   dnf鬼泣装备推荐   dnf鬼泣毕业装备  

【dnf黄金雄鹰图腾怎么升级】dnf黄金雄鹰图腾怎么得 黄金雄鹰图腾出现概率介绍

DNF游戏中成功建造传说图腾的小伙伴可以一次性拿到20个图腾精华,而普通的和特殊也才只给到6个,是普通 特殊的3倍还多,难怪这么多的玩家追求黄金雄鹰图腾了,毕竟有了它,组合出传说的概率非常的高。 为dnf资讯

2021-02-25 18:54:41  

[dnf起源剧情]dnf起源版本公会改动一览 dnf起源版本公会有哪些变动

全新的起源版本已经到来,这次改版的改动很大,甚至有些小伙伴都在游戏中迷路了,那么在全新的起源版本中公会有哪些变化呢?下面就让我们一起去了解一下DNF起源版本公会改动吧! DNF起源版本公会改动一览起dnf资讯

2021-02-25 18:54:41  

德特尔兽人族|dnf兽人族的特别宝物礼盒有什么 兽人族的特别宝物礼盒选择建议

兽人族的特别宝物礼盒打开后,可以在两种宝物礼盒中选择一种,远古兽人族的神秘宝物礼盒、兽人族英雄的宝珠礼盒,很多小伙伴不知道怎么选择才好,小编今天带来一篇DNF兽人族的特别宝物礼盒选择建议,希望大家喜dnf资讯

2021-02-25 18:54:41   怪物猎人世界老练的兽人族学者   兽人族永不为奴除非