Exemplo n.º 1
0
 public function build()
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->_fields['CharacterId']);
     $writer->putUI16LE($this->_fields['Depth']);
     return $writer->output();
 }
Exemplo n.º 2
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->_CharacterID);
     $bitmapFormat = $this->_BitmapFormat;
     $writer->putUI8($bitmapFormat);
     $writer->putUI16LE($this->_BitmapWidth);
     $writer->putUI16LE($this->_BitmapHeight);
     if ($bitmapFormat == 3) {
         $writer->putUI8($this->_BitmapColorTableSize - 1);
     }
     $writer->putData($this->_ZlibBitmapData);
     return $writer->output();
 }
Exemplo n.º 3
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     switch ($tagCode) {
         case 5:
             // RemoveObject
             $writer->putUI16LE($this->_characterId);
             $writer->putUI16LE($this->_depth);
             break;
         case 28:
             // RemoveObject2
             $writer->putUI16LE($this->_depth);
             break;
     }
     return $writer->output();
 }
Exemplo n.º 4
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->SoundId);
     // ----
     $writer->putUIBits($this->SoundFormat, 4);
     $writer->putUIBits($this->SoundRate, 2);
     $writer->putUIBit($this->SoundSize);
     // ---
     $writer->putUI32LE($this->SoundSampleCount);
     $writer->putData($this->SoundData);
     return $writer->output();
 }
Exemplo n.º 5
0
Arquivo: Jpeg.php Projeto: yoya/IO_SWF
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     if ($tagCode != 8) {
         // ! JPEGTablesa
         $writer->putUI16LE($this->_CharacterID);
     }
     if ($tagCode == 35) {
         // DefgineBitsJPEG3
         $this->_AlphaDataOffset = strlen($this->_JPEGData);
         $writer->putUI32LE($this->_AlphaDataOffset);
     }
     if ($tagCode != 35) {
         // ! DefgineBitsJPEG3
         $writer->putData($this->_JPEGData);
     } else {
         $writer->putData($this->_JPEGData);
         $writer->putData($this->_ZlibBitmapAlphaData);
     }
     return $writer->output();
 }
Exemplo n.º 6
0
Arquivo: Text.php Projeto: yoya/IO_SWF
 function buildContent($tagCode, $opts = array())
 {
     $opts['tagCode'] = $tagCode;
     $writer = new IO_Bit();
     $writer->putUI16LE($this->_CharacterID);
     IO_SWF_TYPE_RECT::build($writer, $this->_TextBounds);
     IO_SWF_Type_MATRIX::build($writer, $this->_TextMatrix);
     $glyphBits = $this->_GlyphBits;
     // XXX
     $advanceBits = $this->_AdvanceBits;
     // XXX
     $writer->putUI8($glyphBits);
     $writer->putUI8($advanceBits);
     $opts['GlyphBits'] = $glyphBits;
     $opts['AdvanceBits'] = $advanceBits;
     foreach ($this->_TextRecords as $textRecord) {
         IO_SWF_Type_TEXTRECORD::build($writer, $textRecord, $opts);
     }
     $writer->putUI8(0);
     // TEXTRECORD TERMINATER
     return $writer->output();
 }
Exemplo n.º 7
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     if ($tagCode == 59) {
         // DoInitAction
         $writer->putUI16LE($this->_spriteId);
     }
     $action = null;
     for ($i = 0; $i < count($this->_actions); $i++) {
         $action = $this->_actions[$i];
         if ($action['Code'] == 0x99 || $action['Code'] == 0x9d) {
             // Jump
             // Find label to jump
             for ($j = 0; $j <= count($this->_actions); $j++) {
                 if (isset($this->_labels[$j]) && $this->_labels[$j] == $this->_branches[$i]) {
                     break;
                 }
             }
             // Calculate new offset
             $branch_offset = 0;
             if ($i < $j) {
                 for ($k = $i + 1; $k < $j; $k++) {
                     $branch_offset += IO_SWF_Tag_Action::actionLength($this->_actions[$k]);
                 }
             } else {
                 for ($k = $i; $k >= $j; $k--) {
                     $branch_offset -= IO_SWF_Tag_Action::actionLength($this->_actions[$k]);
                 }
             }
             if ($action['Code'] == 0x99) {
                 // Jump
                 $action['BranchOffset'] = $branch_offset;
             }
             if ($action['Code'] == 0x9d) {
                 // If
                 $action['Offset'] = $branch_offset;
             }
         }
         IO_SWF_Type_Action::build($writer, $action);
     }
     if (is_null($action) === false && $action['Code'] !== 0) {
         $writer->putUI8(0);
         // ActionEndFlag
     }
     return $writer->output();
 }
Exemplo n.º 8
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->_buttonId);
     $opts['tagCode'] = $tagCode;
     if ($tagCode == 34) {
         // DefineButton2
         $writer->putUIBits($this->_reservedFlags, 7);
         $writer->putUIBit($this->_trackAsMenu);
         list($offset_actionOffset, $dummy) = $writer->getOffset();
         $writer->putUI16LE(0);
         // dummy;
     }
     foreach ($this->_characters as $character) {
         IO_SWF_Type_BUTTONRECORD::build($writer, $character, $opts);
     }
     $writer->putUI8(0);
     // terminater of button record
     if ($tagCode == 34) {
         // DefineButton2
         $actions = array();
         if (is_null($this->_actions) === false) {
             list($offset_buttonCondition, $dummy) = $writer->getOffset();
             $writer->setUI16LE($offset_buttonCondition - $offset_actionOffset, $offset_actionOffset);
             foreach ($this->_actions as $idx => $action) {
                 if (isset($this->_actions[$idx + 1]) === false) {
                     $opts['lastAction'] = true;
                 } else {
                     $opts['lastAction'] = false;
                 }
                 IO_SWF_Type_BUTTONCONDACTION::build($writer, $action, $opts);
             }
         }
     } else {
         foreach ($this->_actions as $action) {
             IO_SWF_Type_Action::build($writer, $action);
         }
         $writer->putUI8(0);
         // terminator of actions
     }
     return $writer->output();
 }
Exemplo n.º 9
0
 function buildContent($tagCode, $opts = array())
 {
     $isMorph = $tagCode == 46 || $tagCode == 84;
     $writer = new IO_Bit();
     if (empty($opts['noShapeId'])) {
         $writer->putUI16LE($this->_shapeId);
     }
     $opts = array('tagCode' => $tagCode);
     if ($isMorph === false) {
         IO_SWF_Type_RECT::build($writer, $this->_shapeBounds);
         // 描画スタイル
         IO_SWF_Type_FILLSTYLEARRAY::build($writer, $this->_fillStyles, $opts);
         IO_SWF_Type_LINESTYLEARRAY::build($writer, $this->_lineStyles, $opts);
         // 描画枠
         $opts['fillStyleCount'] = count($this->_fillStyles);
         $opts['lineStyleCount'] = count($this->_lineStyles);
         IO_SWF_Type_SHAPE::build($writer, $this->_shapeRecords, $opts);
     } else {
         IO_SWF_Type_RECT::build($writer, $this->_startBounds);
         IO_SWF_Type_RECT::build($writer, $this->_endBounds);
         $writer->byteAlign();
         list($offset_offset, $dummy) = $writer->getOffset();
         $this->_offset = $writer->putUI32LE(0);
         // at first, write dummy
         // 描画スタイル
         IO_SWF_Type_FILLSTYLEARRAY::build($writer, $this->_morphFillStyles, $opts);
         IO_SWF_Type_LINESTYLEARRAY::build($writer, $this->_morphLineStyles, $opts);
         // 描画枠
         $opts['fillStyleCount'] = count($this->_morphFillStyles);
         $opts['lineStyleCount'] = count($this->_morphLineStyles);
         // StartEdge
         IO_SWF_Type_SHAPE::build($writer, $this->_startEdge, $opts);
         // EndEdge
         $writer->byteAlign();
         list($end_edge_offset, $dummy) = $writer->getOffset();
         $this->_offset = $end_edge_offset - $offset_offset - 4;
         $writer->setUI32LE($this->_offset, $offset_offset);
         IO_SWF_Type_SHAPE::build($writer, $this->_endEdge, $opts);
     }
     return $writer->output();
 }
Exemplo n.º 10
0
Arquivo: Font.php Projeto: yoya/IO_SWF
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->FontID);
     //
     $fontFlagsHasLayout = is_null($this->FontAscent) ? 0 : 1;
     //
     $writer->putUIBit($fontFlagsHasLayout);
     $writer->putUIBit($this->FontFlagsShiftJIS);
     $writer->putUIBit($this->FontFlagsSmallText);
     $writer->putUIBit($this->FontFlagsANSI);
     $writer->putUIBit($this->FontFlagsWideOffsets);
     $writer->putUIBit($this->FontFlagsWideCodes);
     $writer->putUIBit($this->FontFlagsItalic);
     $writer->putUIBit($this->FontFlagsBold);
     IO_SWF_Type_LANGCODE::build($writer, $this->LanguageCode);
     $fontNameLen = strlen($this->FontName);
     $writer->putUI8($fontNameLen);
     $writer->putData($this->FontName);
     $numGlyphs = count($this->OffsetTable);
     $writer->putUI16LE($numGlyphs);
     if ($numGlyphs === 0) {
         return $writer->output();
         // no glyphs field.
     }
     list($startOfOffsetTable, $dummy) = $writer->getOffset();
     $startOfOffsetTable2 = array();
     if ($this->FontFlagsWideOffsets) {
         foreach ($this->OffsetTable as $idx => $offset) {
             list($startOfOffsetTables[$idx], $dummy) = $writer->getOffset();
             $writer->putUI32LE(0);
             // dummy
         }
     } else {
         foreach ($this->OffsetTable as $idx => $offset) {
             list($startOfOffsetTables[$idx], $dummy) = $writer->getOffset();
             $writer->putUI16LE(0);
             // dummy
         }
     }
     list($startOfcodeTableOffset, $dummy) = $writer->getOffset();
     if ($this->FontFlagsWideOffsets) {
         $writer->putUI32LE(0);
         // dummy
     } else {
         $writer->putUI16LE(0);
         // dummy
     }
     $opts['fillStyleCount'] = 1;
     $opts['lineStyleCount'] = 0;
     foreach ($this->GlyphShapeTable as $idx => $glyphShape) {
         list($startOfGlyphShape, $dummy) = $writer->getOffset();
         if ($this->FontFlagsWideOffsets) {
             $writer->setUI32LE($startOfGlyphShape - $startOfOffsetTable, $startOfOffsetTables[$idx]);
         } else {
             $writer->setUI16LE($startOfGlyphShape - $startOfOffsetTable, $startOfOffsetTables[$idx]);
         }
         IO_SWF_Type_SHAPE::build($writer, $glyphShape, $opts);
         $writer->byteAlign();
     }
     //
     list($startOfCodeTable, $dummy) = $writer->getOffset();
     $codeTableOffset = $startOfCodeTable - $startOfOffsetTable;
     if ($this->FontFlagsWideOffsets) {
         $writer->setUI32LE($codeTableOffset, $startOfcodeTableOffset);
     } else {
         $writer->setUI16LE($codeTableOffset, $startOfcodeTableOffset);
     }
     if ($this->FontFlagsWideCodes) {
         foreach ($this->CodeTable as $c) {
             $writer->putUI16LE($c);
         }
     } else {
         foreach ($this->CodeTable as $c) {
             $writer->putUI8($c);
         }
     }
     if ($fontFlagsHasLayout) {
         $writer->putSI16LE($this->FontAscent);
         $writer->putSI16LE($this->FontDescent);
         $writer->putSI16LE($this->FontLeading);
         foreach ($this->FontAdvanceTable as $fontAdvance) {
             $writer->putSI16LE($fontAdvance);
         }
         foreach ($this->FontBoundsTable as $fontBounds) {
             IO_SWF_TYPE_RECT::build($writer, $fontBounds);
         }
         if (is_null($this->FontKerningTable)) {
             $writer->putUI16LE(0);
         } else {
             $kerningCount = count($this->FontKerningTable);
             $writer->putUI16LE($kerningCount);
             $opts['FontFlagsWideCodes'] = $this->FontFlagsWideCodes;
             foreach ($this->FontKerningTable as $fontKerning) {
                 IO_SWF_TYPE_KERNINGRECORD::build($writer, $fontKerning, $opts);
             }
         }
     }
     return $writer->output();
 }
Exemplo n.º 11
0
Arquivo: Tag.php Projeto: yoya/IO_SWF
 function build($opts = array())
 {
     $code = $this->code;
     if (is_null($this->content)) {
         $this->content = $this->buildTagContent();
     }
     $length = strlen($this->content);
     $writer = new IO_Bit();
     switch ($code) {
         case 6:
             // DefineBitsJPEG
         // DefineBitsJPEG
         case 21:
             // DefineBitsJPEG2
         // DefineBitsJPEG2
         case 35:
             // DefineBitsJPEG3
         // DefineBitsJPEG3
         case 20:
             // DefineBitsLossless
         // DefineBitsLossless
         case 36:
             // DefineBitsLossless2
         // DefineBitsLossless2
         case 19:
             // SoundStreamBlock
             $longFormat = true;
             break;
         default:
             $longFormat = false;
             break;
     }
     if ($longFormat === false && $length < 0x3f) {
         $tagAndLength = $code << 6 | $length;
         $writer->putUI16LE($tagAndLength);
     } else {
         $tagAndLength = $code << 6 | 0x3f;
         $writer->putUI16LE($tagAndLength);
         $writer->putUI32LE($length);
     }
     return $writer->output() . $this->content;
 }
Exemplo n.º 12
0
 public function build()
 {
     $writer = new IO_Bit();
     foreach ($this->_actions as $index => $d) {
         $writer->putUI8($d['ActionCode']);
         if ($d['Length'] == 0) {
             continue;
         }
         $writer->putUI16LE($d['Length']);
         $writer->putData($d['Content']);
     }
     return $writer->output();
 }
Exemplo n.º 13
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->CharacterID);
     IO_SWF_Type_RECT::build($writer, $this->Bounds);
     // ----
     $hasText = is_null($this->InitialText) ? 0 : 1;
     $hasTextColor = is_null($this->TextColor) ? 0 : 1;
     $hasMaxLength = is_null($this->MaxLength) ? 0 : 1;
     $hasFont = is_null($this->FontID) ? 0 : 1;
     $hasFontClass = is_null($this->FontClass) ? 0 : 1;
     $hasLayout = is_null($this->Align) ? 0 : 1;
     // ----
     $writer->byteAlign();
     $writer->putUIBit($hasText);
     $writer->putUIBit($this->WordWrap);
     $writer->putUIBit($this->Multiline);
     $writer->putUIBit($this->Password);
     $writer->putUIBit($this->ReadOnly);
     $writer->putUIBit($hasTextColor);
     $writer->putUIBit($hasMaxLength);
     $writer->putUIBit($hasFont);
     // ----
     $writer->putUIBit($hasFontClass);
     $writer->putUIBit($this->AutoSize);
     $writer->putUIBit($hasLayout);
     $writer->putUIBit($this->NoSelect);
     $writer->putUIBit($this->Border);
     $writer->putUIBit($this->WasStatic);
     $writer->putUIBit($this->HTML);
     $writer->putUIBit($this->UseOutlines);
     if ($hasFont) {
         $writer->putUI16LE($this->FontID);
     }
     if ($hasFontClass) {
         IO_SWF_Type_String::build($writer, $this->FontClass);
     }
     if ($hasFont) {
         $writer->putUI16LE($this->FontHeight);
     }
     if ($hasTextColor) {
         IO_SWF_Type_RGBA::build($writer, $this->TextColor);
     }
     if ($hasMaxLength) {
         $writer->putUI16LE($this->MaxLength);
     }
     if ($hasLayout) {
         $writer->putUI8($this->Align);
         $writer->putUI16LE($this->LeftMargin);
         $writer->putUI16LE($this->RightMargin);
         $writer->putUI16LE($this->Indent);
         $writer->putSI16LE($this->Leading);
     }
     IO_SWF_Type_String::build($writer, $this->VariableName);
     if ($hasText) {
         IO_SWF_Type_String::build($writer, $this->InitialText);
     }
     return $writer->output();
 }