encoding

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeNumeric      = 1
	ModeAlphanumeric = 2
	ModeByte         = 4
	ModeKanji        = 8
)
View Source
const (
	ECLevelL = 0
	ECLevelM = 1
	ECLevelQ = 2
	ECLevelH = 3
)

Variables

This section is empty.

Functions

func AlphanumericValue

func AlphanumericValue(b byte) (int, bool)

func ApplyMask

func ApplyMask(matrix [][]bool, maskPattern, version int)

func BestEncodingMode

func BestEncodingMode(data []byte) int

func BestMaskPattern

func BestMaskPattern(baseMatrix [][]bool, ecLevel, version int) int

func BlockCount

func BlockCount(version, ecLevel int) (int, int)

func BuildMatrix

func BuildMatrix(version int) [][]bool

func Capacity

func Capacity(version, ecLevel, mode int) int

func CloneMatrix

func CloneMatrix(matrix [][]bool) [][]bool

func DataCapacity

func DataCapacity(version, ecLevel int) int

func DataCodewords

func DataCodewords(version, ecLevel int) int

func ECCodewords

func ECCodewords(version, ecLevel int) int

func EncodeEC

func EncodeEC(data []byte, ecCount int) []byte

func EncodeECBlocks

func EncodeECBlocks(dataBlocks [][]byte, ecPerBlock int) [][]byte

func GeneratorPoly

func GeneratorPoly(degree int) []int

func IsAlphanumeric

func IsAlphanumeric(b byte) bool

func IsNumeric

func IsNumeric(b byte) bool

func MatrixSize

func MatrixSize(version int) int

func MinVersionForData

func MinVersionForData(dataLen, ecLevel int) (int, error)

func NewMatrix

func NewMatrix(version int) [][]bool

func PenaltyScore

func PenaltyScore(matrix [][]bool, _ int) int

func PlaceAlignmentPattern

func PlaceAlignmentPattern(matrix [][]bool, _, row, col int)

func PlaceAllAlignmentPatterns

func PlaceAllAlignmentPatterns(matrix [][]bool, version int)

func PlaceAllFinderPatterns

func PlaceAllFinderPatterns(matrix [][]bool, version int)

func PlaceDarkModule

func PlaceDarkModule(matrix [][]bool, version int)

func PlaceDataBits

func PlaceDataBits(matrix [][]bool, dataBits []bool, version int)

func PlaceFinderPattern

func PlaceFinderPattern(matrix [][]bool, row, col int)

func PlaceFormatInfo

func PlaceFormatInfo(matrix [][]bool, ecLevel, maskPattern int)

func PlaceTimingPatterns

func PlaceTimingPatterns(matrix [][]bool, version int)

func PlaceVersionInfo

func PlaceVersionInfo(matrix [][]bool, version int)

func PrintMatrix

func PrintMatrix(matrix [][]bool) string

func RemoveMask

func RemoveMask(matrix [][]bool, maskPattern, version int)

func VerifyMatrixSize

func VerifyMatrixSize(matrix [][]bool, version int) error

Types

type QRCode

type QRCode struct {
	Version     int
	Size        int
	Modules     [][]bool
	ECLevel     int
	MaskPattern int
	Data        []byte
	Metadata    map[string]string
}

func Encode

func Encode(data []byte, ecLevel, version int) (*QRCode, error)

Encode creates a QR code from the given data with auto-selected mask pattern.

func EncodeWithMask

func EncodeWithMask(data []byte, ecLevel, version, maskPattern int) (*QRCode, error)

EncodeWithMask creates a QR code from the given data with the specified mask pattern. Use maskPattern -1 for auto-selection (same as Encode).

type VersionInfo

type VersionInfo struct {
	Version             int
	TotalCodewords      int
	DataCodewords       int
	ECBlocks            int
	ECCodewordsPerBlock int
	NumGroups           int
	Group1Blocks        int
	Group1DataCodewords int
	Group2Blocks        int
	Group2DataCodewords int
}

func GetVersionInfo

func GetVersionInfo(version, ecLevel int) (*VersionInfo, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL