コード例 #1
0
ファイル: Daruma.php プロジェクト: nfephp-org/posprint
 /**
  * Insert a image.
  * DLE X m xL xH yL yH d1....dk
  *  m   Mode    Vertical Dot Density    Horizontal Dot Density
  *  0 Normal         200 dpi                200 dpi
  *  1 Double-width   200 dpi                100 dpi
  *  2 Double-height  100 dpi                200 dpi
  *  3 Quadruple      100 dpi                100 dpi
  *
  * @param  string $filename Path to image file
  * @param  float  $width
  * @param  float  $height
  * @param  int    $size     0-normal 1-Double Width 2-Double Heigth 3-Quadruple
  * @throws RuntimeException
  */
 public function putImage($filename = '', $width = null, $height = null, $size = 0)
 {
     try {
         $img = new Graphics($filename, $width, $height);
     } catch (RuntimeException $e) {
         throw new RuntimeException($e->getMessage());
     } catch (InvalidArgumentException $e) {
         throw new RuntimeException($e->getMessage());
     }
     $size = self::validateInteger($size, 0, 3, 0);
     $imgHeader = self::dataHeader(array($img->getWidth(), $img->getHeight()), true);
     $this->buffer->write(self::DLE . 'X' . chr($size) . $imgHeader . $img->getRasterImage());
 }
コード例 #2
0
 /**
  * Insert a image.
  *
  * @param  string $filename Path to image file
  * @param  float  $width
  * @param  float  $height
  * @param  int    $size     0-normal 1-Double Width 2-Double Heigth
  * @throws RuntimeException
  */
 public function putImage($filename = '', $width = null, $height = null, $size = 0)
 {
     try {
         $img = new Graphics($filename, $width, $height);
     } catch (RuntimeException $e) {
         throw new RuntimeException($e->getMessage());
     } catch (InvalidArgumentException $e) {
         throw new RuntimeException($e->getMessage());
     }
     $size = self::validateInteger($size, 0, 3, 0);
     $imgHeader = self::dataHeader(array($img->getWidth(), $img->getHeight()), true);
     $tone = '0';
     $colors = '1';
     $xm = ($size & self::IMG_DOUBLE_WIDTH) == self::IMG_DOUBLE_WIDTH ? chr(2) : chr(1);
     $ym = ($size & self::IMG_DOUBLE_HEIGHT) == self::IMG_DOUBLE_HEIGHT ? chr(2) : chr(1);
     $header = $tone . $xm . $ym . $colors . $imgHeader;
     $this->sendGraphicsData('0', 'p', $header . $img->getRasterImage());
     $this->sendGraphicsData('0', '2');
 }