But the code will not work on vb6.0
"yxq" <ga...@163.net> 写入消息新闻:OTRm6zI5...@TK2MSFTNGP10.phx.gbl...
The SWF File Format
Specification(http://homepages.tig.com.au/~dkl/swf/SWFfileformat.html)
My vb.net code
**************************************************************
Public Class SWFInfo
Private header As String
Private RECTdata As String
Private nBits As String
Private mxMin As Int32
Private mxMax As Int32
Private myMin As Int32
Private myMax As Int32
Private mheigt as Int32
Private mwidth As Int32
Public ReadOnly Property Width()
Get
Return mwidth
End Get
End Property
Public ReadOnly Property Height()
Get
Return mheigt
End Get
End Property
Public Function ReadHeader(ByVal fileName)
Const ForReading As Short = 1
Const ForWriting As Short = 2
Const ForAppending As Short = 8
Dim fso, f As Object
fso = CreateObject("Scripting.FileSystemObject")
f = fso.OpenTextFile(fileName, ForReading)
header = f.Read(21)
RECTdata = DecToBin(Asc(Mid(header, 9, 1)), 8)
RECTdata = RECTdata & DecToBin(Asc(Mid(header, 10, 1)), 8)
RECTdata = RECTdata & DecToBin(Asc(Mid(header, 11, 1)), 8)
RECTdata = RECTdata & DecToBin(Asc(Mid(header, 12, 1)), 8)
RECTdata = RECTdata & DecToBin(Asc(Mid(header, 13, 1)), 8)
RECTdata = RECTdata & DecToBin(Asc(Mid(header, 14, 1)), 8)
RECTdata = RECTdata & DecToBin(Asc(Mid(header, 15, 1)), 8)
RECTdata = RECTdata & DecToBin(Asc(Mid(header, 16, 1)), 8)
RECTdata = RECTdata & DecToBin(Asc(Mid(header, 17, 1)), 8)
nBits = Mid(RECTdata, 1, 5)
nBits = BinToDec(nBits)
mxMin = BinToDec(Mid(RECTdata, 6, nBits))
mxMax = BinToDec(Mid(RECTdata, 6 + nBits * 1, nBits))
myMin = BinToDec(Mid(RECTdata, 6 + nBits * 2, nBits))
myMax = BinToDec(Mid(RECTdata, 6 + nBits * 3, nBits))
mheigt = CInt((myMax - myMin) / 20)
mwidth = CInt((mxMax - mxMin) / 20)
End Function
Private Function DecToBin(ByRef inNumber As Object, ByRef OutLenStr
As Object) As String
Dim binary As String
Do While inNumber >= 1
binary = binary & inNumber Mod 2
inNumber = inNumber \ 2
Loop
binary = binary & New String("0", OutLenStr - Len(binary))
Return StrReverse(binary)
End Function
Private Function BinToDec(ByRef inBin As Object) As Int32
Dim counter As Int32
Dim temp As Int32
Dim Value As Int32
inBin = StrReverse(inBin)
temp = 0
For counter = 1 To Len(inBin)
If counter = 1 Then
Value = 1
Else
Value = Value * 2
End If
temp = temp + CDbl(Mid(inBin, counter, 1)) * Value
Next
Return temp
End Function
End Class
"yxq" <ga...@163.net> 写入消息新闻:%23g7p6AN...@TK2MSFTNGP11.phx.gbl...
Exactly how is the frame size calculated? The link you provided shows
it is a RECT type, and then that is defined elsewhere using some sort of
variable bit encoding. Can you find more info about that? I don't see how
the header can be a fixed size (20 bytes) if the number of bits is variable....
In any case, I'd suggest you go the binary route and treat it something like
a Random Access record. Once you have the structure defined (properly)
it would be a quick matter to get the info.
See this section on Random Access:
HTH
LFS