function parseContent($tagCode, $content, $opts = array()) { $reader = new IO_Bit(); $reader->input($content); $this->_buttonId = $reader->getUI16LE(); $opts['tagCode'] = $tagCode; if ($tagCode == 34) { // DefineButton2 $this->_reservedFlags = $reader->getUIBits(7); $this->_trackAsMenu = $reader->getUIBit(); list($offset_actionOffset, $dummy) = $reader->getOffset(); $this->_actionOffset = $reader->getUI16LE(); } $characters = array(); while ($reader->getUI8() != 0) { $reader->incrementOffset(-1, 0); // 1 byte back $characters[] = IO_SWF_Type_BUTTONRECORD::parse($reader, $opts); } $this->_characters = $characters; if ($tagCode == 34) { // DefineButton2 // TODO: skip ActionOffset - CurrentOffsetUntilCharactersField $actions = array(); if ($this->_actionOffset > 0) { list($offset_buttonCondition, $dummy) = $reader->getOffset(); if ($offset_actionOffset + $this->_actionOffset != $offset_buttonCondition) { // TODO: warning $reader->setOffset($offset_actionOffset + $this->_actionOffset, 0); } while (true) { $action = IO_SWF_Type_BUTTONCONDACTION::parse($reader, $opts); $actions[] = $action; if ($action['CondActionSize'] == 0) { break; // last action } } $this->_actions = $actions; } else { $this->_actions = null; } } else { $actions = array(); while ($reader->getUI8() != 0) { $reader->incrementOffset(-1, 0); // 1 byte back $actions[] = IO_SWF_Type_Action::parse($reader); } $this->_actions = $actions; } return true; }
function _form_26($tag) { // PlaceObject2 $reader = new IO_Bit(); $reader->input($tab['Content']); $placeFlag = $reader->getUI8(); $depth = $reader->getUI16LE(); if ($placeFlag & 0x2) { $characterId = $reader->getUI16LE(); } // }
function parseContent($tagCode, $content, $opts = array()) { $reader = new IO_Bit(); $reader->input($content); $this->_CharacterID = $reader->getUI16LE(); $bitmapFormat = $reader->getUI8(); $this->_BitmapFormat = $bitmapFormat; $this->_BitmapWidth = $reader->getUI16LE(); $this->_BitmapHeight = $reader->getUI16LE(); if ($bitmapFormat == 3) { $this->_BitmapColorTableSize = $reader->getUI8() + 1; } $this->_ZlibBitmapData = $reader->getDataUntil(false); }
function parseContent($tagCode, $content, $opts = array()) { $reader = new IO_Bit(); $reader->input($content); switch ($tagCode) { case 5: // RemoveObject $this->_characterId = $reader->getUI16LE(); $this->_depth = $reader->getUI16LE(); break; case 28: // RemoveObject2 $this->_depth = $reader->getUI16LE(); break; } return true; }
function parseContent($tagCode, $content, $opts = array()) { $reader = new IO_Bit(); $reader->input($content); $this->CharacterID = $reader->getUI16LE(); $this->Bounds = IO_SWF_Type_RECT::parse($reader); // ---- $reader->byteAlign(); $hasText = $reader->getUIBit(); $this->WordWrap = $reader->getUIBit(); $this->Multiline = $reader->getUIBit(); $this->Password = $reader->getUIBit(); $this->ReadOnly = $reader->getUIBit(); $hasTextColor = $reader->getUIBit(); $hasMaxLength = $reader->getUIBit(); $hasFont = $reader->getUIBit(); // ---- $hasFontClass = $reader->getUIBit(); $this->AutoSize = $reader->getUIBit(); $hasLayout = $reader->getUIBit(); $this->NoSelect = $reader->getUIBit(); $this->Border = $reader->getUIBit(); $this->WasStatic = $reader->getUIBit(); $this->HTML = $reader->getUIBit(); $this->UseOutlines = $reader->getUIBit(); if ($hasFont) { $this->FontID = $reader->getUI16LE(); } if ($hasFontClass) { $this->FontClass = IO_SWF_Type_String::parse($reader); } if ($hasFont) { $this->FontHeight = $reader->getUI16LE(); } if ($hasTextColor) { $this->TextColor = IO_SWF_Type_RGBA::parse($reader); } if ($hasMaxLength) { $this->MaxLength = $reader->getUI16LE(); } if ($hasLayout) { $this->Align = $reader->getUI8(); $this->LeftMargin = $reader->getUI16LE(); $this->RightMargin = $reader->getUI16LE(); $this->Indent = $reader->getUI16LE(); $this->Leading = $reader->getSI16LE(); } $this->VariableName = IO_SWF_Type_String::parse($reader); if ($hasText) { $this->InitialText = IO_SWF_Type_String::parse($reader); } }
function parseContent($tagCode, $content, $opts = array()) { $reader = new IO_Bit(); $reader->input($content); if ($tagCode == 59) { // DoInitAction $this->_spriteId = $reader->getUI16LE(); } $i = 0; while ($reader->hasNextData(1)) { list($byteOffset, $dummy) = $reader->getOffset(); $action = IO_SWF_Type_Action::parse($reader); list($nextByteOffset, $dummy) = $reader->getOffset(); // $this->_byteOffsetTable[$i] = $byteOffset; $this->_byteSizeTable[$i] = $nextByteOffset - $byteOffset; $recordOffsetToByteOffset[$i] = $byteOffset; $byteOffsetToRecordOffset[$byteOffset] = $i; // $this->_actions[] = $action; $i++; } if ($i > 0) { $recordOffsetToByteOffset[$i] = $nextByteOffset; $byteOffsetToRecordOffset[$nextByteOffset] = $i; $byteOffsetToRecordOffset[$nextByteOffset] = $i; } $label_num = 0; foreach ($this->_actions as $i => $action) { if ($action['Code'] == 0x99) { // Jump $branch_offset = $action['BranchOffset']; } else { if ($action['Code'] == 0x9d) { // If $branch_offset = $action['Offset']; } else { continue; } } $targetByteOffset = $recordOffsetToByteOffset[$i + 1] + $branch_offset; if (isset($byteOffsetToRecordOffset[$targetByteOffset])) { $targetRecordOffset = $byteOffsetToRecordOffset[$targetByteOffset]; if (isset($this->_labels[$targetRecordOffset]) === false) { $this->_labels[$targetRecordOffset] = $targetRecordOffset; } $this->_branches[$i] = $this->_labels[$targetRecordOffset]; } } }
function parseContent($tagCode, $content, $opts = array()) { $reader = new IO_Bit(); $reader->input($content); $this->SoundId = $reader->getUI16LE(); // --- $this->SoundFormat = $reader->getUIBits(4); $this->SoundRate = $reader->getUIBits(2); $this->SoundSize = $reader->getUIBit(); $this->SoundType = $reader->getUIBit(); // --- $this->SoundSampleCount = $reader->getUI32LE(); $this->SoundData = $reader->getDataUntil(false); }
function parseContent($tagCode, $content, $opts = array()) { $reader = new IO_Bit(); $reader->input($content); if ($tagCode != 8) { // ! JPEGTable $this->_CharacterID = $reader->getUI16LE(); } if ($tagCode == 35) { // DefgineBitsJPEG3 $alphaDataOffset = $reader->getUI32LE(); $this->_AlphaDataOffset = $alphaDataOffset; } if ($tagCode != 35) { // ! DefgineBitsJPEG3 $this->_JPEGData = $reader->getDataUntil(false); } else { $this->_JPEGData = $reader->getData($alphaDataOffset); $this->_ZlibBitmapAlphaData = $reader->getDataUntil(false); } }
function parseContent($tagCode, $content, $opts = array()) { // DefineMorphShape, DefineMorphShape2 $isMorph = $tagCode == 46 || $tagCode == 84; $reader = new IO_Bit(); $reader->input($content); $this->_shapeId = $reader->getUI16LE(); $opts = array('tagCode' => $tagCode, 'isMorph' => $isMorph); if ($isMorph === false) { // 描画スタイル $this->_shapeBounds = IO_SWF_TYPE_RECT::parse($reader); if ($tagCode == 83) { // DefineShape4 $this->_edgeBounds = IO_SWF_TYPE_RECT::parse($reader); $this->_reserved = $reader->getUIBits(6); $this->_usesNonScalingStrokes = $reader->getUIBit(); $this->_UsesScalingStrokes = $reader->getUIBit(); } $this->_fillStyles = IO_SWF_TYPE_FILLSTYLEARRAY::parse($reader, $opts); $this->_lineStyles = IO_SWF_TYPE_LINESTYLEARRAY::parse($reader, $opts); // 描画枠 $this->_shapeRecords = IO_SWF_Type_SHAPE::parse($reader, $opts); } else { $this->_startBounds = IO_SWF_TYPE_RECT::parse($reader); $this->_endBounds = IO_SWF_TYPE_RECT::parse($reader); list($offset_offset, $dummy) = $reader->getOffset(); $this->_offset = $reader->getUI32LE(); // 描画スタイル $this->_morphFillStyles = IO_SWF_TYPE_FILLSTYLEARRAY::parse($reader, $opts); $this->_morphLineStyles = IO_SWF_TYPE_LINESTYLEARRAY::parse($reader, $opts); // 描画枠 $this->_startEdge = IO_SWF_Type_SHAPE::parse($reader, $opts); list($end_edge_offset, $dummy) = $reader->getOffset(); if ($offset_offset + $this->_offset + 4 != $end_edge_offset) { trigger_error("offset_offset({$offset_offset}) + this->_offset({$this->_offset}) + 4 != end_edge_offset({$end_edge_offset})", E_USER_WARNING); $reader->setOffset($offset_offset + $this->_offset + 4, 0); } $this->_endEdge = IO_SWF_Type_SHAPE::parse($reader, $opts); } }
function parseContent($tagCode, $content, $opts = array()) { $opts['tagCode'] = $tagCode; $reader = new IO_Bit(); $reader->input($content); $this->_CharacterID = $reader->getUI16LE(); $this->_TextBounds = IO_SWF_TYPE_RECT::parse($reader); $this->_TextMatrix = IO_SWF_Type_MATRIX::parse($reader); $glyphBits = $reader->getUI8(); $advanceBits = $reader->getUI8(); $this->_GlyphBits = $glyphBits; $this->_AdvanceBits = $advanceBits; $textRecords = array(); $opts['GlyphBits'] = $glyphBits; $opts['AdvanceBits'] = $advanceBits; while ($reader->getUI8() != 0) { $reader->incrementOffset(-1, 0); // 1 byte back $textRecords[] = IO_SWF_Type_TEXTRECORD::parse($reader, $opts); } $this->_TextRecords = $textRecords; }
function parseChunkData() { if (isset($this->detail)) { return; } $detailData = array(); $id = $this->id; $reader = new IO_Bit(); $reader->input($this->data); $this->data = null; // XXX switch ($id) { // INFO sub-chunks case 'ifil': $detailData['sfVersionMajor'] = $reader->getUI16LE(); $detailData['sfVersionMinor'] = $reader->getUI16LE(); break; case 'INAM': $detailData['sfName'] = $this->data; // String break; case 'isng': $detailData['sfEngine'] = $this->data; // String break; case 'IENG': $detailData['sfEngineers'] = $this->data; // String break; case 'ISFT': $detailData['sfTools'] = $this->data; // String break; case 'ICMT': $detailData['Comments'] = $this->data; // String break; case 'ICOP': $detailData['Copyright'] = $this->data; // String break; // sdta sub-chunks // sdta sub-chunks case 'smpl': $detailData['Samples'] = $this->data; // String break; // pdta sub-chunks // pdta sub-chunks case 'phdr': $detailData = array(); while ($reader->hasNextData()) { $preset = array(); $presetName = explode("", $reader->getData(20)); $preset['PresetName'] = $presetName[0]; $preset['Preset'] = $reader->getUI16LE(); $preset['Bank'] = $reader->getUI16LE(); $preset['PresetBagNdx'] = $reader->getUI16LE(); $preset['Library'] = $reader->getUI32LE(); $preset['Genre'] = $reader->getUI32LE(); $preset['MorphologyGenre'] = $reader->getUI32LE(); $detailData[] = $preset; } break; case 'pbag': $detailData = array(); while ($reader->hasNextData()) { $presetBag = array(); $presetBag['GenNdx'] = $reader->getUI16LE(); $presetBag['ModNdx'] = $reader->getUI16LE(); $detailData[] = $presetBag; } break; case 'pmod': case 'imod': $detailData = array(); while ($reader->hasNextData()) { $sfMod = array(); $sfMod['sfModSrcOper'] = IO_SoundFont_Modulator::parse($reader); $sfMod['sfModDestOper'] = $reader->getUI16LE(); $sfMod['modAmount'] = $reader->getSI16LE(); $sfMod['sfModAmtSrcOper'] = IO_SoundFont_Modulator::parse($reader); $sfMod['sfModTransOper'] = $reader->getUI16LE(); $detailData[] = $sfMod; } break; case 'pgen': case 'igen': $detailData = array(); while ($reader->hasNextData()) { $detailData[] = IO_SoundFont_Generator::parse($reader); } break; case 'inst': $detailData = array(); while ($reader->hasNextData()) { $sfInst = array(); $InstName = explode("", $reader->getData(20)); $sfInst['InstName'] = $InstName[0]; $sfInst['InstBagNdx'] = $reader->getSI16LE(); $detailData[] = $sfInst; } break; case 'ibag': $detailData = array(); while ($reader->hasNextData()) { $presetBag = array(); $presetBag['GenNdx'] = $reader->getUI16LE(); $presetBag['ModNdx'] = $reader->getUI16LE(); $detailData[] = $presetBag; } break; case 'shdr': $detailData = array(); while ($reader->hasNextData()) { $sfSample = array(); $SampleName = explode("", $reader->getData(20)); $sfSample['SampleName'] = $SampleName[0]; $sfSample['Start'] = $reader->getUI32LE(); $sfSample['End'] = $reader->getUI32LE(); $sfSample['StartLoop'] = $reader->getUI32LE(); $sfSample['EndLoop'] = $reader->getUI32LE(); $sfSample['SampleRate'] = $reader->getUI32LE(); $sfSample['OriginalPitch'] = $reader->getUI8(); $sfSample['PitchCorrection'] = $reader->getSI8(); $sfSample['SampleLink'] = $reader->getUI16LE(); $sfSample['SampleType'] = $reader->getUI16LE(); $detailData[] = $sfSample; } break; default: return; // nothing to do break; } $this->detail = $detailData; }
function parseContent($tagCode, $content, $opts = array()) { $reader = new IO_Bit(); $reader->input($content); $this->FontID = $reader->getUI16LE(); $fontFlagsHasLayout = $reader->getUIBit(); $this->FontFlagsShiftJIS = $reader->getUIBit(); $this->FontFlagsSmallText = $reader->getUIBit(); $this->FontFlagsANSI = $reader->getUIBit(); $this->FontFlagsWideOffsets = $reader->getUIBit(); $this->FontFlagsWideCodes = $reader->getUIBit(); $this->FontFlagsItalic = $reader->getUIBit(); $this->FontFlagsBold = $reader->getUIBit(); $this->LanguageCode = IO_SWF_Type_LANGCODE::parse($reader); $fontNameLen = $reader->getUI8(); $this->FontName = $reader->getData($fontNameLen); $numGlyphs = $reader->getUI16LE(); if ($numGlyphs === 0) { return; // no glyphs field. } list($startOfOffsetTable, $dummy) = $reader->getOffset(); if ($this->FontFlagsWideOffsets) { for ($i = 0; $i < $numGlyphs; $i++) { $this->OffsetTable[] = $reader->getUI32LE(); } } else { for ($i = 0; $i < $numGlyphs; $i++) { $this->OffsetTable[] = $reader->getUI16LE(); } } if ($this->FontFlagsWideOffsets) { $codeTableOffset = $reader->getUI32LE(); } else { $codeTableOffset = $reader->getUI16LE(); } for ($i = 0; $i < $numGlyphs; $i++) { $reader->setOffset($startOfOffsetTable + $this->OffsetTable[$i], 0); $this->GlyphShapeTable[] = IO_SWF_Type_SHAPE::parse($reader, $opts); $reader->byteAlign(); } list($startOfOffsetCodeTable, $dummy) = $reader->getOffset(); if ($startOfOffsetCodeTable != $startOfOffsetTable + $codeTableOffset) { trigger_error("startOfOffsetCodeTable:{$startOfOffsetCodeTable} != startOfOffsetTable:{$startOfOffsetTable} + codeTableOffset:{$codeTableOffset}", E_USER_WARNING); } $reader->setOffset($startOfOffsetTable + $codeTableOffset, 0); if ($this->FontFlagsWideCodes) { for ($i = 0; $i < $numGlyphs; $i++) { $this->CodeTable[] = $reader->getUI16LE(); } } else { for ($i = 0; $i < $numGlyphs; $i++) { $this->CodeTable[] = $reader->getUI8(); } } if ($fontFlagsHasLayout) { $this->FontAscent = $reader->getSI16LE(); $this->FontDescent = $reader->getSI16LE(); $this->FontLeading = $reader->getSI16LE(); $this->FontAdvanceTable = array(); for ($i = 0; $i < $numGlyphs; $i++) { $this->FontAdvanceTable[] = $reader->getSI16LE(); } $this->FontBoundsTable = array(); for ($i = 0; $i < $numGlyphs; $i++) { $this->FontBoundsTable[] = IO_SWF_TYPE_RECT::parse($reader); } $kerningCount = $reader->getUI16LE(); if ($kerningCount > 0) { $this->FontKerningTable = array(); $opts['FontFlagsWideCodes'] = $this->FontFlagsWideCodes; for ($i = 0; $i < $kerningCount; $i++) { $this->FontKerningTable[] = IO_SWF_TYPE_KERNINGRECORD::parse($reader, $opts); } } } }
function buildContent($tagCode, $opts = array()) { $writer = new IO_Bit(); switch ($tagCode) { case 4: // PlaceObject $this->_characterId = $writer->getUI16LE(); $this->_depth = $writer->getUI16LE(); $this->_matrix = IO_SWF_Type_MATRIX::parse($writer); if ($writer->hasNextData()) { // optional $this->_colorTransform = IO_SWF_Type_CXFORM::parse($writer); } break; case 26: // PlaceObject2 // if (is_null($this->_characterId) === false) { $this->_placeFlagHasCharacter = 1; } else { $this->_placeFlagHasCharacter = 0; } if (is_null($this->_matrix) === false) { $this->_placeFlagHasMatrix = 1; } else { $this->_placeFlagHasMatrix = 0; } if (is_null($this->_colorTransform) === false) { $this->_placeFlagHasColorTransform = 1; } else { $this->_placeFlagHasColorTransform = 0; } if (is_null($this->_ratio) === false) { $this->_placeFlagHasRatio = 1; } else { $this->_placeFlagHasRatio = 0; } if (is_null($this->_name) === false) { $this->_placeFlagHasName = 1; } else { $this->_placeFlagHasName = 0; } if (is_null($this->_clipDepth) === false) { $this->_placeFlagHasClipDepth = 1; } else { $this->_placeFlagHasClipDepth = 0; } if (is_null($this->_clipActions) === false) { $this->_placeFlagHasClipActions = 1; } else { $this->_placeFlagHasClipActions = 0; } // placeFlag $writer->putUIBit($this->_placeFlagHasClipActions); $writer->putUIBit($this->_placeFlagHasClipDepth); $writer->putUIBit($this->_placeFlagHasName); $writer->putUIBit($this->_placeFlagHasRatio); $writer->putUIBit($this->_placeFlagHasColorTransform); $writer->putUIBit($this->_placeFlagHasMatrix); $writer->putUIBit($this->_placeFlagHasCharacter); $writer->putUIBit($this->_placeFlagMove); // $writer->putUI16LE($this->_depth); if ($this->_placeFlagHasCharacter) { $writer->putUI16LE($this->_characterId); } if ($this->_placeFlagHasMatrix) { IO_SWF_Type_MATRIX::build($writer, $this->_matrix); } if ($this->_placeFlagHasColorTransform) { IO_SWF_Type_CXFORMWITHALPHA::build($writer, $this->_colorTransform); } if ($this->_placeFlagHasRatio) { $writer->putUI16LE($this->_ratio); } if ($this->_placeFlagHasName) { IO_SWF_Type_String::build($writer, $this->_name); } if ($this->_placeFlagHasClipDepth) { $writer->putUI16LE($this->_clipDepth); } if ($this->_placeFlagHasClipActions) { IO_SWF_Type_CLIPACTIONS::build($writer, $this->_clipActions, $opts); } break; } return $writer->output(); }