Documentation ¶
Overview ¶
Package qr encodes QR codes.
Index ¶
- Constants
- type Code
- func Encode(text string, level Level) (*Code, error)
- func EncodeData(data split.Data, level Level) (*Code, error)
- func EncodeMulti(header, data split.Data, version coding.Version, level Level) ([]*Code, error)
- func EncodeText(text string, c split.Charset, eci uint32, level Level) (*Code, error)
- func EncodeTextMulti(text string, c split.Charset, eci uint32, version coding.Version, level Level) ([]*Code, error)
- type Level
- type Reversed
Constants ¶
const ( UTF8 = split.UTF8 // UTF-8 UTF8AsLatin1 = split.UTF8AsLatin1 // UTF-8, byte mode in ISO 8859-1 ShiftJIS = split.ShiftJIS // Shift JIS ASCIICompat = split.ASCIICompat // ASCII-compatible 8 bit encodings )
Predefined Charsets.
const ( Latin1ECI = split.Latin1ECI // ISO 8859-1 ShiftJISECI = split.ShiftJISECI // Shift JIS UTF8ECI = split.UTF8ECI // UTF-8 BinaryECI = split.BinaryECI // 8-bit binary data )
Extended Channel Interpretation assignment numbers.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 Scale int // number of image pixels per QR pixel }
A Code is a square pixel grid. It implements image.Image and direct PNG encoding.
func EncodeData ¶ added in v0.5.0
EncodeData returns an encoding of data at the given error correction level.
func EncodeMulti ¶ added in v0.5.0
EncodeMulti returns an encoding of data split across multiple QR codes with the given version and error correction level. If header is not nil, it is added at the beginning of each code.
func EncodeText ¶ added in v0.5.0
EncodeText returns an encoding of text in the given Charset at the given error correction level. If the Charset is nil, it defaults to UTF8. If eci is not 0, the text is preceded by an ECI mode segment.
func EncodeTextMulti ¶ added in v0.5.0
func EncodeTextMulti(text string, c split.Charset, eci uint32, version coding.Version, level Level) ([]*Code, error)
EncodeTextMulti is a combination of EncodeText and EncodeMulti. The ECI mode segment is encoded in each code.
func (*Code) PNG ¶
PNG returns a PNG image displaying the code.
PNG uses a custom encoder tailored to QR codes. Its compressed size is about 4x away from optimal, but it runs about 20x faster than calling png.Encode on c.Image().
type Level ¶
type Level int
A Level denotes a QR error correction level. From least to most tolerant of errors, they are L, M, Q, H.
type Reversed ¶ added in v0.5.0
type Reversed struct {
*Code
}
Reversed is a Code with colors reversed.
Directories ¶
Path | Synopsis |
---|---|
Package coding implements low-level QR coding details.
|
Package coding implements low-level QR coding details. |
Package gf256 implements arithmetic over the Galois Field GF(256).
|
Package gf256 implements arithmetic over the Galois Field GF(256). |
Package libqrencode wraps the C libqrencode library.
|
Package libqrencode wraps the C libqrencode library. |
Package split splits strings into QR code segments.
|
Package split splits strings into QR code segments. |