/**
  * @return string
  */
 public function encode()
 {
     $packedFields = 0;
     $packedFields |= $this->reserved << 5 & 0x70;
     $packedFields |= $this->disposalMethod << 2 & 0x1c;
     $packedFields |= $this->userInputFlag ? 0x2 : 0x0;
     $packedFields |= $this->transparentColorFlag ? 0x1 : 0x0;
     return "!" . chr($this->blockLabel) . "" . chr($packedFields & 0xff) . DataHandler::packUint16($this->delayTime) . chr($this->transparentColorIndex) . "" . $this->imageDescriptor->encode();
 }
Esempio n. 2
0
 /**
  * @return string
  */
 public function encode()
 {
     $ctSize = BinStringStatic::_strlen($this->colorTable);
     if ($ctSize > 0) {
         $this->colorTableFlag = true;
         $this->colorTableSize = $ctSize / 3;
     } else {
         $this->colorTableFlag = false;
         $this->colorTableSize = 2;
     }
     $packedFields = 0;
     $packedFields |= $this->colorTableFlag ? 0x80 : 0x0;
     $packedFields |= $this->interlaceFlag ? 0x40 : 0x0;
     $packedFields |= $this->sortFlag ? 0x20 : 0x0;
     $packedFields |= $this->reserved << 3 & 0x18;
     $packedFields |= ceil(log($this->colorTableSize) / log(2)) - 1;
     //$packedFields |= $this->ctSizeList[$this->colorTableSize];
     // The lookup table is faster, but I wanted the Pedantic version.
     $r = DataHandler::packUint16($this->screenLeftPos) . DataHandler::packUint16($this->screenTopPos) . DataHandler::packUint16($this->screenWidth) . DataHandler::packUint16($this->screenHeight) . chr($packedFields & 0xff);
     if ($this->colorTableFlag && $this->colorTableSize > 0) {
         $r .= $this->colorTable;
     }
     return "," . $r . $this->lzwMinCodeSize . $this->dataSubBlocks . "";
 }
 /**
  * @return string
  */
 public function encode()
 {
     $ctSize = BinStringStatic::_strlen($this->colorTable);
     if ($ctSize > 0) {
         $this->colorTableFlag = true;
         $this->colorTableSize = $ctSize / 3;
     } else {
         $this->colorTableFlag = false;
         $this->colorTableSize = 2;
     }
     $packedFields = 0;
     $packedFields |= $this->colorTableFlag ? 0x80 : 0x0;
     $packedFields |= $this->colorResolution << 4 & 0x70;
     $packedFields |= $this->sortFlag ? 0x8 : 0x0;
     // For just 8 possible values, the lookup table is faster.
     // the commented line below is the pedantic way of doing it.
     //$packedFields |= ceil(log($this->colorTableSize) / log(2)) - 1;
     $packedFields |= $this->ctSizeList[$this->colorTableSize];
     $r = DataHandler::packUint16($this->screenWidth) . DataHandler::packUint16($this->screenHeight) . chr($packedFields & 0xff) . chr($this->bgColorIndex) . chr($this->pixelAspectRatio == 0 ? 0 : (int) ($this->pixelAspectRatio * 64 / 15));
     if ($this->colorTableFlag && $this->colorTableSize > 0) {
         $r .= $this->colorTable;
     }
     return $r;
 }
Esempio n. 4
0
 /**
  * @return string
  */
 public function encode()
 {
     return "!" . chr($this->blockLabel) . "\f" . DataHandler::packUint16($this->textGridLeftPosition) . DataHandler::packUint16($this->textGridTopPosition) . DataHandler::packUint16($this->textGridWidth) . DataHandler::packUint16($this->textGridHeight) . ord($this->characterCellWidth) . ord($this->characterCellHeight) . ord($this->textFGColorIndex) . ord($this->textBGColorIndex) . $this->dataSubBlocks . "";
 }