encode

abstract fun encode(contents: String): BooleanArray

Encode the contents to boolean array expression of one-dimensional barcode. Start code and end code should be included in result, and side margins should not be included.

Return

a boolean[] of horizontal pixels (false = white, true = black)

Parameters

contents

barcode contents to encode


open fun encode(contents: String, hints: Map<EncodeHintType, *>?): BooleanArray

Can be overwritten if the encode requires to read the hints map. Otherwise it defaults to encode.

Return

a boolean[] of horizontal pixels (false = white, true = black)

Parameters

contents

barcode contents to encode

hints

encoding hints


override fun encode(contents: String, format: BarcodeFormat, width: Int, height: Int): BitMatrix

Encode a barcode using the default settings.

Return

BitMatrix representing encoded barcode image

Parameters

contents

The contents to encode in the barcode

format

The barcode format to generate

width

The preferred width in pixels

height

The preferred height in pixels

Throws

if contents cannot be encoded legally in a format


open override fun encode(contents: String, format: BarcodeFormat, width: Int, height: Int, hints: Map<EncodeHintType, *>?): BitMatrix

Encode the contents following specified format. width and height are required size. This method may return bigger size BitMatrix when specified size is too small. The user can set both width and height to zero to get minimum size barcode. If negative value is set to width or height, IllegalArgumentException is thrown.