BarcodeGenerator::dmtx_create_matrix

  1. Bitrix24 API (v. 23.675.0)
  2. ui
  3. BarcodeGenerator
  4. dmtx_create_matrix
  • Модуль: ui
  • Путь к файлу: ~/bitrix/modules/ui/lib/barcode/barcodegenerator.php
  • Класс: BitrixUIBarcodeBarcodeGenerator
  • Вызов: BarcodeGenerator::dmtx_create_matrix
private function dmtx_create_matrix($ec_params, $data) {
	/* Create matrix. */
	$rheight = $ec_params[8] + 2;
	$rwidth = $ec_params[9] + 2;
	$height = $ec_params[6] * $rheight;
	$width = $ec_params[7] * $rwidth;
	$bitmap = array();
	for ($y = 0; $y < $height; $y++) {
		$row = array();
		for ($x = 0; $x < $width; $x++) {
			$row[] = ((
				((($x + $y) % 2) == 0) ||
				(($x % $rwidth) == 0) ||
				(($y % $rheight) == ($rheight - 1))
			) ? 1 : 0);
		}
		$bitmap[] = $row;
	}
	/* Create data region. */
	$rows = $ec_params[6] * $ec_params[8];
	$cols = $ec_params[7] * $ec_params[9];
	$matrix = array();
	for ($y = 0; $y < $rows; $y++) {
		$row = array();
		for ($x = 0; $x < $width; $x++) {
			$row[] = null;
		}
		$matrix[] = $row;
	}
	$this->dmtx_place_data($matrix, $rows, $cols, $data);
	/* Copy into matrix. */
	for ($yy = 0; $yy < $ec_params[6]; $yy++) {
		for ($xx = 0; $xx < $ec_params[7]; $xx++) {
			for ($y = 0; $y < $ec_params[8]; $y++) {
				for ($x = 0; $x < $ec_params[9]; $x++) {
					$row = $yy * $ec_params[8] + $y;
					$col = $xx * $ec_params[9] + $x;
					$b = $matrix[$row][$col];
					if (is_null($b)) continue;
					$row = $yy * $rheight + $y + 1;
					$col = $xx * $rwidth + $x + 1;
					$bitmap[$row][$col] = $b;
				}
			}
		}
	}
	/* Return matrix. */
	return array($height, $width, $bitmap);
}

Добавить комментарий