By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,205 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
yxq
I found a link
http://www.4guysfromrolla.com/webtec...102001-1.shtml

But the code will not work on vb6.0

"yxq" <ga***@163.net> 写入消息新闻:OT**************@TK2MSFTNGP10.phx.gbl ...
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!

Nov 21 '05 #2

P: n/a
yxq
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> 写入消息新闻:%2****************@TK2MSFTNGP11.phx.g bl...
I found a link
http://www.4guysfromrolla.com/webtec...102001-1.shtml

But the code will not work on vb6.0

"yxq" <ga***@163.net> 写入消息新闻:OT**************@TK2MSFTNGP10.phx.gbl ...
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!


Nov 21 '05 #3

P: n/a

"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/de...FileAccess.asp

HTH
LFS

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.