Esempio n. 1
0
 /**
  * Put a image
  * GS v0 m xL xH yL yH d1 ... dk
  *
  * @param string $filename
  * @param intger $width
  * @param integer $height
  * @param integer $size resolution relation
  * @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);
     //get xL xH yL yH
     $imgHeader = self::dataHeader(array($img->getWidth(), $img->getHeight()), true);
     //send graphics command to printer
     $this->buffer->write(self::GS . 'v0' . chr($size) . $imgHeader . $img->getRasterImage());
 }