getPointsInTwips() public static method

gets points in twips
public static getPointsInTwips ( float $value ) : integer
$value float
return integer
Exemplo n.º 1
0
 /**
  * code for parsing the wmf is originally from: http://www.fpdf.de/downloads/addons/55/
  * as an addon for FPDF, written by Martin HALL-MAY
  */
 private function setImageDimension()
 {
     $headerSize = $this->getHeaderSize();
     fseek($this->_stream, $headerSize);
     while (!feof($this->_stream)) {
         $recordInfo = unpack('Lsize/Sfunc', fread($this->_stream, 6));
         // size of record given in WORDs (= 2 bytes)
         $size = $recordInfo['size'];
         // func is number of GDI function
         $func = $recordInfo['func'];
         // parameters are read as one block and processed
         // as necessary by the case statement below.
         // the data are stored in little-endian format and are unpacked using:
         // s - signed 16-bit int
         // S - unsigned 16-bit int (or WORD)
         // L - unsigned 32-bit int (or DWORD)
         // NB. parameters to GDI functions are stored in reverse order
         // however structures are not reversed,
         // e.g. POINT { int x, int y } where x=3000 (0x0BB8) and y=-1200 (0xFB50)
         // is stored as B8 0B 50 FB
         if ($size > 3) {
             $params = fread($this->_stream, 2 * ($size - 3));
         }
         switch ($func) {
             case 0x20c:
                 // SetWindowExt
                 $sizes = array_reverse(unpack('s2', $params));
                 $this->setImageWidth(PHPRtfLite_Unit::getPointsInTwips($sizes[0]));
                 $this->setImageHeight(PHPRtfLite_Unit::getPointsInTwips($sizes[1]));
                 return;
             case 0x0:
                 return;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * gets rtf image height
  *
  * @return integer
  */
 private function getImageRtfHeight()
 {
     if ($this->_height > 0) {
         return PHPRtfLite_Unit::getUnitInTwips($this->_height);
     }
     $imageHeight = $this->_imageHeight ? $this->_imageHeight : 100;
     if ($this->_width > 0) {
         $imageWidth = $this->_imageWidth ? $this->_imageWidth : 100;
         $height = $imageHeight / $imageWidth * $this->_width;
         return PHPRtfLite_Unit::getUnitInTwips($height);
     }
     return PHPRtfLite_Unit::getPointsInTwips($imageHeight);
 }