microqr

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(data []byte, opts ...EncodeOptions) (image.Image, error)

Types

type EncodeOptions

type EncodeOptions func(opts *encodeOptions)

func WithKanji

func WithKanji(use bool) EncodeOptions

func WithLevel

func WithLevel(lv Level) EncodeOptions

WithLevel sets the error correction level. The default level is LevelM. If the level is invalid, it panics.

func WithModuleSize

func WithModuleSize(size float64) EncodeOptions

WithModuleSize sets the module size. The default size is 1.

func WithQuietZone added in v0.2.0

func WithQuietZone(n int) EncodeOptions

WithQuietZone sets the quiet zone size. The default size is 4.

func WithWidth added in v0.2.0

func WithWidth(width int) EncodeOptions

type Level

type Level int

Level is a error correction level.

const (
	LevelCheck Level = 0b10
	LevelL     Level = 0b01
	LevelM     Level = 0b00
	LevelQ     Level = 0b11
)

func (Level) IsValid added in v0.2.0

func (lv Level) IsValid() bool

IsValid returns true if the level is valid.

func (Level) String

func (lv Level) String() string

type Mask

type Mask int

Mask is a mask pattern.

const (
	Mask0 Mask = iota
	Mask1
	Mask2
	Mask3

	MaskAuto Mask = -1
)

type Mode

type Mode uint8
const (
	// ModeNumeric is number mode.
	// The Data must be ascii characters [0-9].
	ModeNumeric Mode = 0b000

	// ModeAlphanumeric is alphabet and number mode.
	// The Data must be ascii characters [0-9A-Z $%*+\-./:].
	ModeAlphanumeric Mode = 0b001

	// ModeBytes is 8-bit bytes mode.
	// The Data can include any bytes.
	ModeBytes Mode = 0b010

	// ModeKanji is Japanese Kanji mode.
	ModeKanji Mode = 0b011

	ModeTerminated Mode = 0b0000
)

func (Mode) String

func (mode Mode) String() string

type QRCode

type QRCode struct {
	Version  Version
	Level    Level
	Mask     Mask
	Segments []Segment
}

func DecodeBitmap

func DecodeBitmap(img *bitmap.Image) (*QRCode, error)

func New

func New(data []byte, opts ...EncodeOptions) (*QRCode, error)

func (*QRCode) Encode

func (qr *QRCode) Encode(opts ...EncodeOptions) (image.Image, error)

func (*QRCode) EncodeToBitmap

func (qr *QRCode) EncodeToBitmap() (*bitmap.Image, error)

EncodeToBitmap encodes QR Code into bitmap image.

type Segment

type Segment struct {
	Mode Mode
	Data []byte
}

type Version

type Version int

Version is a version of microQR code.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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