Generate two characters for a number: In lower and higher parts, or more parts as needed.
private static intLowHigh ( integer $input, integer $length ) | ||
$input | integer | Input number |
$length | integer | The number of bytes to output (1 - 4). |
/** * Convert widths and heights to characters. Used before sending graphics to set the size. * * @param array $inputs * @param boolean $long True to use 4 bytes, false to use 2 * @return string */ private static function dataHeader(array $inputs, $long = true) { $outp = array(); foreach ($inputs as $input) { if ($long) { $outp[] = Printer::intLowHigh($input, 2); } else { self::validateInteger($input, 0, 255, __FUNCTION__); $outp[] = chr($input); } } return implode("", $outp); }