Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

0 views
Skip to first unread message

yxq

unread,
Dec 17, 2004, 6:05:53 PM12/17/04
to
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!


yxq

unread,
Dec 18, 2004, 2:07:15 AM12/18/04
to
I found a link
http://www.4guysfromrolla.com/webtech/tips/t102001-1.shtml

But the code will not work on vb6.0

"yxq" <ga...@163.net> 写入消息新闻:OTRm6zI5...@TK2MSFTNGP10.phx.gbl...

yxq

unread,
Dec 18, 2004, 7:51:11 PM12/18/04
to
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" <ga...@163.net> 写入消息新闻:%23g7p6AN...@TK2MSFTNGP11.phx.gbl...

Larry Serflaten

unread,
Dec 18, 2004, 11:26:42 PM12/18/04
to

"yxq" <ga...@163.net> wrote
> 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/default.asp?url=/library/en-us/vbcn7/html/vaconDeclaringVariablesForRandomFileAccess.asp

HTH
LFS

0 new messages