static function parse(&$reader, $opts = array()) { $buttonrecord = array(); $reader->byteAlign(); $buttonrecord['ButtonReserved'] = $reader->getUIBits(2); // must be 0 $buttonHasBlendMode = $reader->getUIBit(); $buttonHasFilterList = $reader->getUIBit(); $buttonrecord['ButtonHasBlandMode'] = $buttonHasBlendMode; $buttonrecord['ButtonHasFilterList'] = $buttonHasFilterList; $buttonrecord['ButtonStateHitTest'] = $reader->getUIBit(); $buttonrecord['ButtonStateDown'] = $reader->getUIBit(); $buttonrecord['ButtonStateOver'] = $reader->getUIBit(); $buttonrecord['ButtonStateUp'] = $reader->getUIBit(); $buttonrecord['CharacterID'] = $reader->getUI16LE(); $buttonrecord['PlaceDepth'] = $reader->getUI16LE(); $buttonrecord['PlaceMatrix'] = IO_SWF_Type_MATRIX::parse($reader); if ($opts['tagCode'] == 34) { // DefineButton2 $buttonrecord['ColorTransform'] = IO_SWF_Type_CXFORMWITHALPHA::parse($reader); } else { $buttonrecord['ColorTransform'] = IO_SWF_Type_CXFORM::parse($reader); } if ($opts['tagCode'] == 34 && $opts['Version'] >= 8) { // DefineButton2 & SWF8 later if ($buttonHasFilterList == 1) { $buttonrecord['FilterList'] = IO_SWF_Type_FILTERLIST::parse($reader); } if ($buttonHasBlendMode == 1) { $buttonrecord['BlendMode'] = $reader->getUI8(); } } return $buttonrecord; }
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; }
static function parse(&$reader, $opts = array()) { $tagCode = $opts['tagCode']; $isMorph = $tagCode == 46 || $tagCode == 84; $fillStyle = array(); $fillStyleType = $reader->getUI8(); $fillStyle['FillStyleType'] = $fillStyleType; switch ($fillStyleType) { case 0x0: // solid fill if ($isMorph === false) { if ($tagCode < 32) { // 32:DefineShape3 $fillStyle['Color'] = IO_SWF_Type_RGB::parse($reader); } else { $fillStyle['Color'] = IO_SWF_Type_RGBA::parse($reader); } } else { $fillStyle['StartColor'] = IO_SWF_Type_RGBA::parse($reader); $fillStyle['EndColor'] = IO_SWF_Type_RGBA::parse($reader); } break; case 0x10: // linear gradient fill // linear gradient fill case 0x12: // radial gradient fill // radial gradient fill case 0x13: // focal gradient fill // 8 and later if ($isMorph === false) { $fillStyle['GradientMatrix'] = IO_SWF_Type_MATRIX::parse($reader); } else { $fillStyle['StartGradientMatrix'] = IO_SWF_Type_MATRIX::parse($reader); $fillStyle['EndGradientMatrix'] = IO_SWF_Type_MATRIX::parse($reader); } $reader->byteAlign(); if ($isMorph === false) { $fillStyle['SpreadMode'] = $reader->getUIBits(2); $fillStyle['InterpolationMode'] = $reader->getUIBits(2); $numGradients = $reader->getUIBits(4); } else { $numGradients = $reader->getUI8(); } $fillStyle['GradientRecords'] = array(); for ($j = 0; $j < $numGradients; $j++) { $gradientRecord = array(); if ($isMorph === false) { $gradientRecord['Ratio'] = $reader->getUI8(); if ($tagCode < 32) { // 32:DefineShape3 $gradientRecord['Color'] = IO_SWF_Type_RGB::parse($reader); } else { $gradientRecord['Color'] = IO_SWF_Type_RGBA::parse($reader); } } else { // Morph $gradientRecord['StartRatio'] = $reader->getUI8(); $gradientRecord['StartColor'] = IO_SWF_Type_RGBA::parse($reader); $gradientRecord['EndRatio'] = $reader->getUI8(); $gradientRecord['EndColor'] = IO_SWF_Type_RGBA::parse($reader); } $fillStyle['GradientRecords'][] = $gradientRecord; } if ($fillStyleType == 0x13) { // focal gradient fill // 8 and later $gradientRecord['FocalPoint'] = $reader->getUI8(); } break; case 0x40: // repeating bitmap fill // repeating bitmap fill case 0x41: // clipped bitmap fill // clipped bitmap fill case 0x42: // non-smoothed repeating bitmap fill // non-smoothed repeating bitmap fill case 0x43: // non-smoothed clipped bitmap fill $fillStyle['BitmapId'] = $reader->getUI16LE(); if ($isMorph === false) { $fillStyle['BitmapMatrix'] = IO_SWF_Type_MATRIX::parse($reader); } else { $fillStyle['StartBitmapMatrix'] = IO_SWF_Type_MATRIX::parse($reader); $fillStyle['EndBitmapMatrix'] = IO_SWF_Type_MATRIX::parse($reader); } break; default: throw new IO_SWF_Exception("Unknown FillStyleType={$fillStyleType} tagCode={$tagCode}"); } return $fillStyle; }
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(); }