How to get the actual size (width*height) of flash file?

  • Thread starter Thread starter yxq
  • Start date Start date
Y

yxq

Hello,
I use the com component "shockwave flash object" to play flash file, but how
to get the actual size (width*height) of flash file but no control size?
thank you!
 
I have converted the code into vb.net to get width and height, but the
return value is not right.
Can anyone help me to view the code below? Thank you very much!

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 said:
I have converted the code into vb.net to get width and height, but the
return value is not right.

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:

http://msdn.microsoft.com/library/d...aconDeclaringVariablesForRandomFileAccess.asp

HTH
LFS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top