I am trying to write a C++ program that I can call that will grab images and make them into an animation. I was wondering if anyone would be able to give me an example on how SWF is formated and how to set tags to help me with this.
Printable View
I am trying to write a C++ program that I can call that will grab images and make them into an animation. I was wondering if anyone would be able to give me an example on how SWF is formated and how to set tags to help me with this.
http://sourceforge.net/projects/ming
The other thing to look at is the SWF File Format documentation from Adobe.
Thanks a lot. I have been reading the SWF file format but it helps me more if I can see what they are talking about. But the ming files should help a lot thanks again.
Does anyone know if the RECORDHEADER wants the length in bits or in bytes?
The lower 6 bits of the RECORDHEADER specify the number of BYTES in the tag (up to 63 bytes). If the tag length is set to 0x3f (all 1's) then the RECORDHEADER is followed by a 32bit field that specifies the length of the tag (up to 4GB).
thanks again.
Sorry but I have another question. When it comes to reading in jpegs to create the jpegtable I know to read between the SOI and EOI markers. But when it comes to define bits what am I reading in? The entire file with the encoding table? or am I suppose to parse that out and just use the rest of the file as my data for the definebits tag?
You've got me there... I'd have to RTFM myself to figure that one out :)
Would you know a site or documentation that I could read that might help me there? :)
There's a PHP tool called jpg2swf that converts JPEG images to SWF files. It's supposed to be standalone so it should have all the info you're looking for. If you know C++ you can probably grok PHP well enough to figure out what's going on.
Once again thanks :)
Ok so I was reading through the code that he wrote and I was stumped lol.
Maybe you might be able to tell me whats going on.
// TAG SHOWFRAME
// id (1) and length (0)
$swf.=chr(64);
$swf.=chr(0);
I get this part. He is using 64 because the way swf files are written out.
since SHOWFRAME's id is 1 in binary that gives us:
00000001
since all headers are 2bytes (16bits) the high 10 bits are the id and the
low 6 order bits are the length we have to shift our bits.
so 00000001 << 6 gives us 01000000 which gives us 64. BINGO.
But here comes the confusing part.
// TAG PLACEOBJECT
// id (26) and length (6)
$swf.=chr(134);
$swf.=chr(6);
If we do the same thing here: id = 26 so that gives us:
00011010 then we shift it by 6 again giving us....
00000110 10000000
then we tack on 6 which is 00000110.
so lets do some bit arithmetic :P
00000110 10000000
| 00000000 00000110
----------------------
00000110 10000110
6 134
so his code to my understanding should be:
$swf.=chr(6);
$swf.=chr(134);
but his is reversed and I have no clue why.
At first I thought that it might be because of flashes endianess
being little endian.
but that would just cause the bits to be moved around not swaping
entire bytes. Also if that was the case why didn't he move the bytes
around in the other part of his code?
Endianness can refer to the bit-order, but more commonly it refers to byte ordering. Boing back to the original example of the RECORDHEADER, the SWF File format SDK says this...
Quote:
The TagCodeAndLength field is a two-byte word, not a bit field of 10 bits followed by a bit field of 6 bits. The little-endian byte ordering of a SWF file makes these two layouts different.
So switching entire bytes around isn't uncommon? But why would he not be consistent with it?
It depends on whether the layout specifies two bytes or a short (16bit) struct. You don't change the byte order for individual bytes, but the bytes in a short would be reversed.
Hey Tim I need your genius again :P. I'm trying to write out a RECT struct set up how its set up in an swf file.
nbits[5] 5 bits....
xmin[n] n bits....
xmax[n] n bits....
ymin[n] n bits....
ymax[n] n bits....
Only problem is you can't write out bits in C++ only bytes. Do you know of a way it can be done?
Is there some type of padding header that I don't know about?
You have to virtualize the bit stream you want to write. Instead of writing out a bit at a time, you build up a bit string in memory and only write it out when you have a full byte's worth of data. There are classes out there you can google that will help you with this if you don't want to write your own.
I was reading in the appendix A of the SWF specs pdf and I noticed they said that structures are padded to the byte so when reading in the next dword we don't have to worry about being in another byte. So am I suppose to byte align all of the tags as well?
Each struct is padded out to the nearest full byte (i.e. extra bits at the end of the struct that you can ignore) so when you start reading the next struct or member from the TAG it should start on a byte boundary.
Hey Tim could you tell me how the swf matrix works? I have looking at the php sample you told me about and he uses 217 for the first 8 bits of the matrix which I don't understand because the first bit states it has a scale value, then the next five bits state the scale that he uses needs 22 bits. He commented his code saying us is using a 20:20 (1:1) but for 20 you only need 5 bits. Would you happen to know why?
Also in the documentation it states that scaleX and scaleY are stored as 16.16 fixed point values. Whats the purpose of declaring the bits if its already set to 16.16? Or am I miss interpreting that.
Ok I figured out pretty much what is going on. I'm just not understanding why they are using 22 bits. Also by using 22 bits how will that lay out in the 16.16 fixed point value for the scaleX and scaleY of the matrix? Does that make it 22.22?
"The other thing to look at is the SWF File Format documentation from Adobe. ".
Can someone tell me how to use the above specification for C++? is it all about constructing an XML file and compile it using some magic library so we will get an SWF as output ? what do we need to know to use the document,
Can someone enlighten me on how to use that document.
Thanks in advance.
Regards,
Ashok Srinivasan.
The SWF file format specification describes the exact binary format of an SWF file. Your C++ application will have to turn whatever representation you want to use into that binary format to create an SWF file.
I browsed through the web and came across SSWF. Though i have not yet completely explored it but it seems to be giving a promising feeling. Meanwhile are there any other C++ libraries that can compile SWF ?
Regards,
Ashok Srinivasan.
Wow. Treasure, Treasure , Treasure. A page of tools and libraries for SWF generation.
More Tools
Claus Wahlers just released this little gem :)
http://wiki.github.com/claus/as3swf
Quote:
as3swf is a low level Actionscript 3 library to parse, create, modify and publish SWF files.
Alpha version, under active development. Please do not use in production just yet.