tags:

views:

651

answers:

2

According to the swf documentation from Adobe, you should be able to read the individual bytes of a swf to calculate the files size, file dimensions (width and height), version and file type (swf or swc).

I am using javascript to read in the individual bytes and converting them to human readable information but I am running into problems when it comes to file dimensions.

My first question is does any one have a formula to convert from twips (twentieths of a pixel) to pixels? It would seem that dividing by 20 would work, but I am not positive.

My second question is has any one been able to get the file dimensions of a swf file using any language? I am using javascript but I would think that the byte order would be the same in any language.

Thanks

A: 

If you have twips and they really are twentieths of a pixel, wouldn't it just be:

pixels = twips * 20

So you're not dividing by 20, you're multiplying since a twip is a fraction of a pixel.

1 twip = 1/20 pixel
20 twips = 1 pixel
Ryan
That definitely helps - I can't believe I missed that! My numbers are still way off, so I think I am not reading the bytes right.
A: 

Ok - some new info has come up. The reason why I was getting unreliable values for the dimensions of the file is because the file was a 'swc' (compressed) and not an 'swf' (uncompressed). So the hex values are not the true values.

If any one knows how to uncompress the swc to a swf - it would be helpful.

Thanks!