Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Code39Reader

Decodes Code 39 barcodes. Supports "Full ASCII Code 39" if USE_CODE_39_EXTENDED_MODE is set.

author

Sean Owen

see

Code93Reader

Hierarchy

Implements

Index

Constructors

constructor

  • new Code39Reader(usingCheckDigit?: boolean, extendedMode?: boolean): Code39Reader
  • Creates a reader that can be configured to check the last character as a check digit, or optionally attempt to decode "extended Code 39" sequences that are used to encode the full ASCII character set.

    Parameters

    • Default value usingCheckDigit: boolean = false

      if true, treat the last data character as a check digit, not data, and verify that the checksum passes.

    • Default value extendedMode: boolean = false

      if true, will attempt to decode extended Code 39 sequences in the text.

    Returns Code39Reader

Properties

Private counters

counters: Int32Array

Private decodeRowResult

decodeRowResult: string

Private extendedMode

extendedMode: boolean

Private usingCheckDigit

usingCheckDigit: boolean

Static Private Readonly ALPHABET_STRING

ALPHABET_STRING: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%" = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"

Static Private Readonly ASTERISK_ENCODING

ASTERISK_ENCODING: 148 = 148

Static Private Readonly CHARACTER_ENCODINGS

CHARACTER_ENCODINGS: number[] = [0x034, 0x121, 0x061, 0x160, 0x031, 0x130, 0x070, 0x025, 0x124, 0x064, // 0-90x109, 0x049, 0x148, 0x019, 0x118, 0x058, 0x00D, 0x10C, 0x04C, 0x01C, // A-J0x103, 0x043, 0x142, 0x013, 0x112, 0x052, 0x007, 0x106, 0x046, 0x016, // K-T0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, 0x085, 0x184, 0x0C4, 0x0A8, // U-$0x0A2, 0x08A, 0x02A // /-%]

These represent the encodings of characters, as patterns of wide and narrow bars. The 9 least-significant bits of each int correspond to the pattern of wide and narrow, with 1s representing "wide" and 0s representing narrow.

Methods

decode

decodeRow

reset

  • reset(): void

Static Private decodeExtended

  • decodeExtended(encoded: string): string

Static Private findAsteriskPattern

  • findAsteriskPattern(row: BitArray, counters: Int32Array): number[]

Static Protected patternMatchVariance

  • patternMatchVariance(counters: Int32Array, pattern: Int32Array, maxIndividualVariance: number): number
  • Determines how closely a set of observed counts of runs of black/white values matches a given target pattern. This is reported as the ratio of the total variance from the expected pattern proportions across all pattern elements, to the length of the pattern.

    Parameters

    • counters: Int32Array

      observed counters

    • pattern: Int32Array

      expected pattern

    • maxIndividualVariance: number

      The most any counter can differ before we give up

    Returns number

    ratio of total variance between counters and pattern compared to total pattern size

Static Private patternToChar

  • patternToChar(pattern: number): string

Static Protected recordPattern

  • recordPattern(row: BitArray, start: number, counters: Int32Array): void
  • Records the size of successive runs of white and black pixels in a row, starting at a given point. The values are recorded in the given array, and the number of runs recorded is equal to the size of the array. If the row starts on a white pixel at the given start point, then the first count recorded is the run of white pixels starting from that point; likewise it is the count of a run of black pixels if the row begin on a black pixels at that point.

    throws

    NotFoundException if counters cannot be filled entirely from row before running out of pixels

    Parameters

    • row: BitArray

      row to count from

    • start: number

      offset into row to start at

    • counters: Int32Array

      array into which to record counts

    Returns void

Static Protected recordPatternInReverse

  • recordPatternInReverse(row: BitArray, start: number, counters: Int32Array): void

Static Private toNarrowWidePattern

  • toNarrowWidePattern(counters: Int32Array): number

Generated using TypeDoc