restore files modified by stickler

This commit is contained in:
Frédéric FRANCE 2019-11-03 17:13:27 +01:00
parent 8a247339c3
commit 430be760f3
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
11 changed files with 103 additions and 105 deletions

View File

@ -107,7 +107,7 @@ abstract class EscposImage
*/ */
public function getHeightBytes() public function getHeightBytes()
{ {
return (int) (($this -> imgHeight + 7) / 8); return (int)(($this -> imgHeight + 7) / 8);
} }
/** /**
@ -123,7 +123,7 @@ abstract class EscposImage
*/ */
public function getWidthBytes() public function getWidthBytes()
{ {
return (int) (($this -> imgWidth + 7) / 8); return (int)(($this -> imgWidth + 7) / 8);
} }
/** /**
@ -279,7 +279,7 @@ abstract class EscposImage
return $data; return $data;
} }
do { do {
$byteVal |= (int) $this -> imgData[$y * $widthPixels + $x] << (7 - $bit); $byteVal |= (int)$this -> imgData[$y * $widthPixels + $x] << (7 - $bit);
$x++; $x++;
$bit++; $bit++;
if ($x >= $widthPixels) { if ($x >= $widthPixels) {
@ -356,7 +356,7 @@ abstract class EscposImage
do { do {
$yReal = $y + $yStart; $yReal = $y + $yStart;
if ($yReal < $heightPixels) { if ($yReal < $heightPixels) {
$byteVal |= (int) $this -> imgData[$yReal * $widthPixels + $x] << (7 - $bit); $byteVal |= (int)$this -> imgData[$yReal * $widthPixels + $x] << (7 - $bit);
} }
$y++; $y++;
$bit++; $bit++;

View File

@ -73,7 +73,7 @@ class GdEscposImage extends EscposImage
/* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */ /* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
$cols = imagecolorsforindex($im, imagecolorat($im, $x, $y)); $cols = imagecolorsforindex($im, imagecolorat($im, $x, $y));
// 1 for white, 0 for black, ignoring transparency // 1 for white, 0 for black, ignoring transparency
$greyness = (int) (($cols['red'] + $cols['green'] + $cols['blue']) / 3) >> 7; $greyness = (int)(($cols['red'] + $cols['green'] + $cols['blue']) / 3) >> 7;
// 1 for black, 0 for white, taking into account transparency // 1 for black, 0 for white, taking into account transparency
$black = (1 - $greyness) >> ($cols['alpha'] >> 6); $black = (1 - $greyness) >> ($cols['alpha'] >> 6);
$imgData[$y * $imgWidth + $x] = $black; $imgData[$y * $imgWidth + $x] = $black;

View File

@ -44,7 +44,7 @@ class ImagickEscposImage extends EscposImage
/* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */ /* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */
$cols = $im -> getImagePixelColor($x, $y); $cols = $im -> getImagePixelColor($x, $y);
$cols = $cols -> getcolor(); $cols = $cols -> getcolor();
$greyness = (int) (($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7; // 1 for white, 0 for black $greyness = (int)(($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7; // 1 for white, 0 for black
$imgData[$y * $imgWidth + $x] = (1 - $greyness); // 1 for black, 0 for white $imgData[$y * $imgWidth + $x] = (1 - $greyness); // 1 for black, 0 for white
} }
} }

View File

@ -136,7 +136,7 @@ class EscposPrintBuffer implements PrintBuffer
if ($c == "\r") { if ($c == "\r") {
/* Skip past Windows line endings (raw usage). */ /* Skip past Windows line endings (raw usage). */
continue; continue;
} elseif (self::asciiCheck($c, true)) { } else if (self::asciiCheck($c, true)) {
$outp[$j] = $c; $outp[$j] = $c;
} }
$j++; $j++;

View File

@ -30,9 +30,9 @@ class ApiPrintConnector implements PrintConnector
/** /**
* Construct new connector * Construct new connector
* *
* @param string $host Host * @param string $host
* @param string $printerId Printer Id * @param string $printerId
* @param string $apiToken Api Token * @param string $apiToken
*/ */
public function __construct($host, $printerId, $apiToken) public function __construct($host, $printerId, $apiToken)
{ {
@ -57,7 +57,6 @@ class ApiPrintConnector implements PrintConnector
/** /**
* Finish using this print connector (close file, socket, send * Finish using this print connector (close file, socket, send
* accumulated output, etc). * accumulated output, etc).
* @return void
*/ */
public function finalize() public function finalize()
{ {
@ -95,7 +94,6 @@ class ApiPrintConnector implements PrintConnector
* Write data to the print connector. * Write data to the print connector.
* *
* @param string $data The data to write * @param string $data The data to write
* @return void
*/ */
public function write($data) public function write($data)
{ {

View File

@ -672,7 +672,7 @@ class Printer
$this -> wrapperSend2dCodeData(chr(67), $cn, chr($width)); $this -> wrapperSend2dCodeData(chr(67), $cn, chr($width));
$this -> wrapperSend2dCodeData(chr(68), $cn, chr($heightMultiplier)); $this -> wrapperSend2dCodeData(chr(68), $cn, chr($heightMultiplier));
// Set error correction ratio: 1% to 400% // Set error correction ratio: 1% to 400%
$ec_int = (int) ceil(floatval($ec) * 10); $ec_int = (int)ceil(floatval($ec) * 10);
$this -> wrapperSend2dCodeData(chr(69), $cn, chr($ec_int), '1'); $this -> wrapperSend2dCodeData(chr(69), $cn, chr($ec_int), '1');
// Send content & print // Send content & print
$this -> wrapperSend2dCodeData(chr(80), $cn, $content, '0'); $this -> wrapperSend2dCodeData(chr(80), $cn, $content, '0');
@ -995,7 +995,7 @@ class Printer
public function text($str = "") public function text($str = "")
{ {
self::validateString($str, __FUNCTION__); self::validateString($str, __FUNCTION__);
$this -> buffer -> writeText((string) $str); $this -> buffer -> writeText((string)$str);
} }
/** /**
@ -1010,7 +1010,7 @@ class Printer
self::validateString($str, __FUNCTION__); self::validateString($str, __FUNCTION__);
$this -> connector -> write(self::FS . "&"); $this -> connector -> write(self::FS . "&");
$str = iconv("UTF-8", "GBK//IGNORE", $str); $str = iconv("UTF-8", "GBK//IGNORE", $str);
$this -> buffer -> writeTextRaw((string) $str); $this -> buffer -> writeTextRaw((string)$str);
$this -> connector -> write(self::FS . "."); $this -> connector -> write(self::FS . ".");
} }
@ -1025,7 +1025,7 @@ class Printer
public function textRaw($str = "") public function textRaw($str = "")
{ {
self::validateString($str, __FUNCTION__); self::validateString($str, __FUNCTION__);
$this -> buffer -> writeTextRaw((string) $str); $this -> buffer -> writeTextRaw((string)$str);
} }
/** /**
@ -1098,7 +1098,7 @@ class Printer
$outp = ""; $outp = "";
for ($i = 0; $i < $length; $i++) { for ($i = 0; $i < $length; $i++) {
$outp .= chr($input % 256); $outp .= chr($input % 256);
$input = (int) ($input / 256); $input = (int)($input / 256);
} }
return $outp; return $outp;
} }