http://doruby.kbmj.com/hal_on_rails/20100411/SWF_ を参考にコードを書いてみたのですが、使う機会がなかったのでここに残しておきます。
swf_file.rb
class SwfFile
# @example:
# SwdFile.new("foo.swf")
def initialize(path)
@path = path
end
# @example:
# x_min, x_max, y_min, y_max = swf.stage_size
def stage_size
File.open(@path) do |io|
io.read(8) # header
# どんなに長くても 5+31*4 bitなので16byteで十分
buf = io.read(16).bytes.map { |i|
"%08d" % i.to_s(2)
}.join
# 最初の5bitが以降の区切りの長さ(bit)
l = buf[0, 5].to_i(2)
# 最初の5bitを消しておく
buf[0, 5] = ""
[
buf[0, l], # x_min
buf[l, l], # x_max
buf[l * 2, l], # y_min
buf[l * 3, l], # y_max
].map { |i|
# 1pt=20twips
i.to_i(2) / 20
}
end
end
end