qr

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2014 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resample

func Resample(m image.Image, r image.Rectangle, w, h int) *image.RGBA

Resample returns a resampled copy of the image slice r of m. The returned image has width w and height h.

func ResizeNRGBA

func ResizeNRGBA(m *image.NRGBA, r image.Rectangle, w, h int) *image.RGBA

ResizeNRGBA returns a scaled copy of the RGBA image slice r of m. The returned image has width w and height h.

func ResizeRGBA

func ResizeRGBA(m *image.RGBA, r image.Rectangle, w, h int) *image.RGBA

ResizeRGBA returns a scaled copy of the RGBA image slice r of m. The returned image has width w and height h.

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

func Encode(text string, level Level) (*Code, error)

Encode returns an encoding of text at the given error correction level.

func (*Code) Black

func (c *Code) Black(x, y int) bool

Black returns true if the pixel at (x,y) is black.

func (*Code) Image

func (c *Code) Image() image.Image

Image returns an Image displaying the code.

func (*Code) PNG

func (c *Code) PNG() []byte

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.

const (
	L Level = iota // 20% redundant
	M              // 38% redundant
	Q              // 55% redundant
	H              // 65% redundant
)

Jump to

Keyboard shortcuts

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