Documentation

MatrixUtil
in package

Matrix utility.

Table of Contents

POSITION_ADJUSTMENT_PATTERN  = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]
Position adjustment pattern.
POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE  = [ [null, null, null, null, null, null, null], // Version 1 [6, 18, null, null, null, null, null], // Version 2 [6, 22, null, null, null, null, null], // Version 3 [6, 26, null, null, null, null, null], // Version 4 [6, 30, null, null, null, null, null], // Version 5 [6, 34, null, null, null, null, null], // Version 6 [6, 22, 38, null, null, null, null], // Version 7 [6, 24, 42, null, null, null, null], // Version 8 [6, 26, 46, null, null, null, null], // Version 9 [6, 28, 50, null, null, null, null], // Version 10 [6, 30, 54, null, null, null, null], // Version 11 [6, 32, 58, null, null, null, null], // Version 12 [6, 34, 62, null, null, null, null], // Version 13 [6, 26, 46, 66, null, null, null], // Version 14 [6, 26, 48, 70, null, null, null], // Version 15 [6, 26, 50, 74, null, null, null], // Version 16 [6, 30, 54, 78, null, null, null], // Version 17 [6, 30, 56, 82, null, null, null], // Version 18 [6, 30, 58, 86, null, null, null], // Version 19 [6, 34, 62, 90, null, null, null], // Version 20 [6, 28, 50, 72, 94, null, null], // Version 21 [6, 26, 50, 74, 98, null, null], // Version 22 [6, 30, 54, 78, 102, null, null], // Version 23 [6, 28, 54, 80, 106, null, null], // Version 24 [6, 32, 58, 84, 110, null, null], // Version 25 [6, 30, 58, 86, 114, null, null], // Version 26 [6, 34, 62, 90, 118, null, null], // Version 27 [6, 26, 50, 74, 98, 122, null], // Version 28 [6, 30, 54, 78, 102, 126, null], // Version 29 [6, 26, 52, 78, 104, 130, null], // Version 30 [6, 30, 56, 82, 108, 134, null], // Version 31 [6, 34, 60, 86, 112, 138, null], // Version 32 [6, 30, 58, 86, 114, 142, null], // Version 33 [6, 34, 62, 90, 118, 146, null], // Version 34 [6, 30, 54, 78, 102, 126, 150], // Version 35 [6, 24, 50, 76, 102, 128, 154], // Version 36 [6, 28, 54, 80, 106, 132, 158], // Version 37 [6, 32, 58, 84, 110, 136, 162], // Version 38 [6, 26, 54, 82, 110, 138, 166], // Version 39 [6, 30, 58, 86, 114, 142, 170], ]
Coordinates for position adjustment patterns for each version.
POSITION_DETECTION_PATTERN  = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]
Position detection pattern.
TYPE_INFO_COORDINATES  = [[8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 7], [8, 8], [7, 8], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [0, 8]]
Type information coordinates.
TYPE_INFO_MASK_PATTERN  = 0x5412
Type information mask pattern.
TYPE_INFO_POLY  = 0x537
Type information polynomial.
VERSION_INFO_POLY  = 0x1f25
Version information polynomial.
buildMatrix()  : void
Builds a complete matrix.
clearMatrix()  : void
Clears a given matrix.
removePositionDetectionPatterns()  : void
Removes the position detection patterns from a matrix.
calculateBchCode()  : int
Calculates the BCH code for a value and a polynomial.
embedBasicPatterns()  : void
Embeds basic patterns into a matrix.
embedDarkDotAtLeftBottomCorner()  : void
Embeds a dot at the left bottom corner.
embedDataBits()  : void
Embeds "dataBits" using "getMaskPattern".
embedHorizontalSeparationPattern()  : void
Embeds a single horizontal separation pattern.
embedPositionAdjustmentPattern()  : void
Embeds a single position adjustment pattern.
embedPositionDetectionPattern()  : void
Embeds a single position detection pattern into a byte matrix.
embedPositionDetectionPatternsAndSeparators()  : void
Embeds position detection patterns and separators into a byte matrix.
embedTimingPatterns()  : void
Embeds timing patterns into a matrix.
embedTypeInfo()  : void
Embeds type information into a matrix.
embedVerticalSeparationPattern()  : void
Embeds a single vertical separation pattern.
findMsbSet()  : int
Finds and MSB set.
makeTypeInfoBits()  : void
Generates type information bits and appends them to a bit array.
makeVersionInfoBits()  : void
Generates version information bits and appends them to a bit array.
maybeEmbedPositionAdjustmentPatterns()  : void
Embeds position adjustment patterns if required.
maybeEmbedVersionInfo()  : void
Embeds version information if required.
removePositionDetectionPattern()  : void

Constants

POSITION_ADJUSTMENT_PATTERN

Position adjustment pattern.

private mixed POSITION_ADJUSTMENT_PATTERN = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]

POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE

Coordinates for position adjustment patterns for each version.

private mixed POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = [ [null, null, null, null, null, null, null], // Version 1 [6, 18, null, null, null, null, null], // Version 2 [6, 22, null, null, null, null, null], // Version 3 [6, 26, null, null, null, null, null], // Version 4 [6, 30, null, null, null, null, null], // Version 5 [6, 34, null, null, null, null, null], // Version 6 [6, 22, 38, null, null, null, null], // Version 7 [6, 24, 42, null, null, null, null], // Version 8 [6, 26, 46, null, null, null, null], // Version 9 [6, 28, 50, null, null, null, null], // Version 10 [6, 30, 54, null, null, null, null], // Version 11 [6, 32, 58, null, null, null, null], // Version 12 [6, 34, 62, null, null, null, null], // Version 13 [6, 26, 46, 66, null, null, null], // Version 14 [6, 26, 48, 70, null, null, null], // Version 15 [6, 26, 50, 74, null, null, null], // Version 16 [6, 30, 54, 78, null, null, null], // Version 17 [6, 30, 56, 82, null, null, null], // Version 18 [6, 30, 58, 86, null, null, null], // Version 19 [6, 34, 62, 90, null, null, null], // Version 20 [6, 28, 50, 72, 94, null, null], // Version 21 [6, 26, 50, 74, 98, null, null], // Version 22 [6, 30, 54, 78, 102, null, null], // Version 23 [6, 28, 54, 80, 106, null, null], // Version 24 [6, 32, 58, 84, 110, null, null], // Version 25 [6, 30, 58, 86, 114, null, null], // Version 26 [6, 34, 62, 90, 118, null, null], // Version 27 [6, 26, 50, 74, 98, 122, null], // Version 28 [6, 30, 54, 78, 102, 126, null], // Version 29 [6, 26, 52, 78, 104, 130, null], // Version 30 [6, 30, 56, 82, 108, 134, null], // Version 31 [6, 34, 60, 86, 112, 138, null], // Version 32 [6, 30, 58, 86, 114, 142, null], // Version 33 [6, 34, 62, 90, 118, 146, null], // Version 34 [6, 30, 54, 78, 102, 126, 150], // Version 35 [6, 24, 50, 76, 102, 128, 154], // Version 36 [6, 28, 54, 80, 106, 132, 158], // Version 37 [6, 32, 58, 84, 110, 136, 162], // Version 38 [6, 26, 54, 82, 110, 138, 166], // Version 39 [6, 30, 58, 86, 114, 142, 170], ]

POSITION_DETECTION_PATTERN

Position detection pattern.

private mixed POSITION_DETECTION_PATTERN = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]

TYPE_INFO_COORDINATES

Type information coordinates.

private mixed TYPE_INFO_COORDINATES = [[8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 7], [8, 8], [7, 8], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [0, 8]]

TYPE_INFO_MASK_PATTERN

Type information mask pattern.

private mixed TYPE_INFO_MASK_PATTERN = 0x5412

TYPE_INFO_POLY

Type information polynomial.

private mixed TYPE_INFO_POLY = 0x537

VERSION_INFO_POLY

Version information polynomial.

private mixed VERSION_INFO_POLY = 0x1f25

Methods

removePositionDetectionPatterns()

Removes the position detection patterns from a matrix.

public static removePositionDetectionPatterns(ByteMatrix $matrix) : void

This can be useful if you need to render those patterns separately.

Parameters
$matrix : ByteMatrix
Return values
void

calculateBchCode()

Calculates the BCH code for a value and a polynomial.

private static calculateBchCode(int $value, int $poly) : int
Parameters
$value : int
$poly : int
Return values
int

embedDarkDotAtLeftBottomCorner()

Embeds a dot at the left bottom corner.

private static embedDarkDotAtLeftBottomCorner(ByteMatrix $matrix) : void
Parameters
$matrix : ByteMatrix
Tags
throws
RuntimeException

if a byte was already set to 0

Return values
void

embedDataBits()

Embeds "dataBits" using "getMaskPattern".

private static embedDataBits(BitArray $dataBits, int $maskPattern, ByteMatrix $matrix) : void

For debugging purposes, it skips masking process if "getMaskPattern" is -1. See 8.7 of JISX0510:2004 (p.38) for how to embed data bits.

Parameters
$dataBits : BitArray
$maskPattern : int
$matrix : ByteMatrix
Tags
throws
WriterException

if not all bits could be consumed

Return values
void

embedHorizontalSeparationPattern()

Embeds a single horizontal separation pattern.

private static embedHorizontalSeparationPattern(int $xStart, int $yStart, ByteMatrix $matrix) : void
Parameters
$xStart : int
$yStart : int
$matrix : ByteMatrix
Tags
throws
RuntimeException

if a byte was already set

Return values
void

embedPositionAdjustmentPattern()

Embeds a single position adjustment pattern.

private static embedPositionAdjustmentPattern(int $xStart, int $yStart, ByteMatrix $matrix) : void
Parameters
$xStart : int
$yStart : int
$matrix : ByteMatrix
Return values
void

embedPositionDetectionPattern()

Embeds a single position detection pattern into a byte matrix.

private static embedPositionDetectionPattern(int $xStart, int $yStart, ByteMatrix $matrix) : void
Parameters
$xStart : int
$yStart : int
$matrix : ByteMatrix
Return values
void

embedPositionDetectionPatternsAndSeparators()

Embeds position detection patterns and separators into a byte matrix.

private static embedPositionDetectionPatternsAndSeparators(ByteMatrix $matrix) : void
Parameters
$matrix : ByteMatrix
Return values
void

embedTimingPatterns()

Embeds timing patterns into a matrix.

private static embedTimingPatterns(ByteMatrix $matrix) : void
Parameters
$matrix : ByteMatrix
Return values
void

embedVerticalSeparationPattern()

Embeds a single vertical separation pattern.

private static embedVerticalSeparationPattern(int $xStart, int $yStart, ByteMatrix $matrix) : void
Parameters
$xStart : int
$yStart : int
$matrix : ByteMatrix
Tags
throws
RuntimeException

if a byte was already set

Return values
void

findMsbSet()

Finds and MSB set.

private static findMsbSet(int $value) : int
Parameters
$value : int
Return values
int

makeVersionInfoBits()

Generates version information bits and appends them to a bit array.

private static makeVersionInfoBits(Version $version, BitArray $bits) : void
Parameters
$version : Version
$bits : BitArray
Tags
throws
RuntimeException

if bit array resulted in invalid size

Return values
void

maybeEmbedPositionAdjustmentPatterns()

Embeds position adjustment patterns if required.

private static maybeEmbedPositionAdjustmentPatterns(Version $version, ByteMatrix $matrix) : void
Parameters
$version : Version
$matrix : ByteMatrix
Return values
void

maybeEmbedVersionInfo()

Embeds version information if required.

private static maybeEmbedVersionInfo(Version $version, ByteMatrix $matrix) : void
Parameters
$version : Version
$matrix : ByteMatrix
Return values
void

removePositionDetectionPattern()

private static removePositionDetectionPattern(int $xStart, int $yStart, ByteMatrix $matrix) : void
Parameters
$xStart : int
$yStart : int
$matrix : ByteMatrix
Return values
void

Search results