package coding
import "rsc.io/qr/coding"
Package coding implements low-level QR coding details.
Index ¶
- Constants
- Variables
- type Alpha
- func (s Alpha) Bits(v Version) int
- func (s Alpha) Check() error
- func (s Alpha) Encode(b *Bits, v Version)
- func (s Alpha) String() string
- type Bits
- func (b *Bits) AddCheckBytes(v Version, l Level)
- func (b *Bits) Append(p []byte)
- func (b *Bits) Bits() int
- func (b *Bits) Bytes() []byte
- func (b *Bits) Pad(n int)
- func (b *Bits) Reset()
- func (b *Bits) Write(v uint, nbit int)
- type Code
- type Encoding
- type Level
- type Mask
- type Num
- func (s Num) Bits(v Version) int
- func (s Num) Check() error
- func (s Num) Encode(b *Bits, v Version)
- func (s Num) String() string
- type Pixel
- func OffsetPixel(o uint) Pixel
- func (p Pixel) Offset() uint
- func (p Pixel) Role() PixelRole
- func (p Pixel) String() string
- type PixelRole
- type Plan
- func NewPlan(version Version, level Level, mask Mask) (*Plan, error)
- func (p *Plan) Encode(text ...Encoding) (*Code, error)
- type String
- func (s String) Bits(v Version) int
- func (s String) Check() error
- func (s String) Encode(b *Bits, v Version)
- func (s String) String() string
- type Version
Constants ¶
const MaxVersion = 40
const MinVersion = 1
Variables ¶
Field is the field for QR error correction.
Types ¶
type Alpha ¶
type Alpha string
Alpha is the encoding for alphanumeric data. The valid characters are 0-9A-Z$%*+-./: and space.
func (Alpha) Bits ¶
func (Alpha) Check ¶
func (Alpha) Encode ¶
func (Alpha) String ¶
type Bits ¶
type Bits struct {
// contains filtered or unexported fields
}
func (*Bits) AddCheckBytes ¶
func (*Bits) Append ¶
func (*Bits) Bits ¶
func (*Bits) Bytes ¶
func (*Bits) Pad ¶
func (*Bits) Reset ¶
func (b *Bits) Reset()
func (*Bits) Write ¶
type Code ¶
type Code struct { Bitmap []byte // 1 is black, 0 is white Size int // number of pixels on a side Stride int // number of bytes per row }
A Code is a square pixel grid.
func (*Code) Black ¶
type Encoding ¶
Encoding implements a QR data encoding scheme. The implementations--Numeric, Alphanumeric, and String--specify the character set and the mapping from UTF-8 to code bits. The more restrictive the mode, the fewer code bits are needed.
type Level ¶
type Level int
A Level represents a QR error correction level. From least to most tolerant of errors, they are L, M, Q, H.
func (Level) String ¶
type Mask ¶
type Mask int
A Mask describes a mask that is applied to the QR code to avoid QR artifacts being interpreted as alignment and timing patterns (such as the squares in the corners). Valid masks are integers from 0 to 7.
func (Mask) Invert ¶
type Num ¶
type Num string
Num is the encoding for numeric data. The only valid characters are the decimal digits 0 through 9.
func (Num) Bits ¶
func (Num) Check ¶
func (Num) Encode ¶
func (Num) String ¶
type Pixel ¶
type Pixel uint32
A Pixel describes a single pixel in a QR code.
func OffsetPixel ¶
func (Pixel) Offset ¶
func (Pixel) Role ¶
func (Pixel) String ¶
type PixelRole ¶
type PixelRole uint32
A PixelRole describes the role of a QR pixel.
const ( Position PixelRole // position squares (large) Alignment // alignment squares (small) Timing // timing strip between position squares Format // format metadata PVersion // version pattern Unused // unused pixel Data // data bit Check // error correction check bit Extra )
func (PixelRole) Pixel ¶
func (PixelRole) String ¶
type Plan ¶
type Plan struct { Version Version Level Level Mask Mask DataBytes int // number of data bytes CheckBytes int // number of error correcting (checksum) bytes Blocks int // number of data blocks Pixel [][]Pixel // pixel map }
A Plan describes how to construct a QR code with a specific version, level, and mask.
func NewPlan ¶
NewPlan returns a Plan for a QR code with the given version, level, and mask.
func (*Plan) Encode ¶
type String ¶
type String string
String is the encoding for 8-bit data. All bytes are valid.
func (String) Bits ¶
func (String) Check ¶
func (String) Encode ¶
func (String) String ¶
type Version ¶
type Version int
A Version represents a QR version. The version specifies the size of the QR code: a QR code with version v has 4v+17 pixels on a side. Versions number from 1 to 40: the larger the version, the more information the code can store.
func (Version) DataBytes ¶
DataBytes returns the number of data bytes that can be stored in a QR code with the given version and level.
func (Version) String ¶
Source Files ¶
qr.go
- Version
- v0.2.0 (latest)
- Published
- Jun 5, 2018
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 1 minute ago –
Tools for package owners.