SWF DefineShape parser
DefineShape1,2,3のバイナリを切り出すプログラムをPHPで作ってみました。
プログラムの概要
$this->_shapeBounds = IO_SWF_Type::parseRECT($reader); $this->_parseFILLSTYLEARRAY($reader); $this->_parseLINESTYLEARRAY($reader); $reader->byteAlign(); $numFillBits = $reader->getUIBits(4); $numLineBits = $reader->getUIBits(4); while ($done === false) { $typeFlag = $reader->getUIBit(); if ($typeFlag == 0) { $endOfShape = $reader->getUIBits(5); if ($endOfShape == 0) { $done = true; } else { // StyleChangeRecord ... } } else { $straightFlag = $reader->getUIBit(); if ($straightFlag) { // StraightEdgeRecord ... $stateNewStyles = $reader->getUIBit(); if ($stateNewStyles) { $this->_parseFILLSTYLEARRAY($reader); $this->_parseLINESTYLEARRAY($reader); $reader->byteAlign(); $numFillBits = $reader->getUIBits(4); $numLineBits = $reader->getUIBits(4); } } else { // CurvedEdgeRecord ... } } }
実行結果
pear channel-discover openpear.org pear install openpear/IO_Bit pear install openpear/IO_SWF
でインストールして、pear ディレクトリの sample/swfdump.php にファイルを渡すと動作します。
ShapeId: 1 ShapeBounds: (-7.75, -7.75) - (7.75, 7.75) FillStyles: solid fill: #0066ff LineStyles: ShapeRecords: ChangeStyle: MoveTo: (-7.75, -7.75) FillStyle: 0|1 LineStyle: 0 StraightEdge: MoveTo: (7.75, -7.75) StraightEdge: MoveTo: (7.75, 7.75) StraightEdge: MoveTo: (-7.75, 7.75) StraightEdge: MoveTo: (-7.75, -7.75)
こんな感じです。
TODO
SVG に変換して表示できれば…