package qr
import "rsc.io/qr"
Package qr encodes QR codes.
Index ¶
- type Code
- func Encode(text string, level Level) (*Code, error)
- func (c *Code) Black(x, y int) bool
- func (c *Code) Image() image.Image
- func (c *Code) PNG() []byte
- type Level
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 Encode ¶
Encode returns an encoding of text at the given error correction level.
func (*Code) Black ¶
Black returns true if the pixel at (x,y) is black.
func (*Code) Image ¶
Image returns an Image displaying the 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 2x 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.
Source Files ¶
png.go qr.go
Directories ¶
Path | Synopsis |
---|---|
coding | Package coding implements low-level QR coding details. |
gf256 | Package gf256 implements arithmetic over the Galois Field GF(256). |
libqrencode | Package libqrencode wraps the C libqrencode library. |
- Version
- v0.1.0
- Published
- Nov 21, 2016
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 5 hours ago –
Tools for package owners.