Mike42\Escpos\EscposImage::getWidthBytes PHP Method

getWidthBytes() public method

public getWidthBytes ( ) : integer
return integer Number of bytes to represent a row of this image
    public function getWidthBytes()
    {
        return (int) (($this->imgWidth + 7) / 8);
    }

Usage Example

Example #1
0
 /**
  * Print an image, using the older "bit image" command. This creates padding on the right of the image,
  * if its width is not divisible by 8.
  * 
  * Should only be used if your printer does not support the graphics() command.
  * 
  * @param EscposImage $img The image to print
  * @param EscposImage $size Size modifier for the image.
  */
 function bitImage(EscposImage $img, $size = self::IMG_DEFAULT)
 {
     self::validateInteger($size, 0, 3, __FUNCTION__);
     $header = self::dataHeader(array($img->getWidthBytes(), $img->getHeight()), true);
     $this->connector->write(self::GS . "v0" . chr($size) . $header);
     $this->connector->write($img->toRasterFormat());
 }