rmqr

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

Overview

Package rmqr handles rMRQ Codes.

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

WithKanji enables the kanji mode. The default mode is true. If it's enabled, Shift-JIS encoding is used for kanji mode.

func WithLevel

func WithLevel(lv Level) EncodeOptions

WithLevel sets the error correction level. The default value is LevelM.

func WithModuleSize

func WithModuleSize(size float64) EncodeOptions

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

func WithPriority

func WithPriority(priority Priority) EncodeOptions

WithPriority sets the priority for selecting the version.

func WithQuietZone added in v0.2.0

func WithQuietZone(n int) EncodeOptions

WithQuietZone sets the quiet zone size. The default value is 2.

func WithWidth added in v0.2.0

func WithWidth(width int) EncodeOptions

WithWidth sets the width of the image. The larger of the image width calculated from WithModuleSize and the image width specified with WithWidth is used. The image height is calculated from the image width.

type Level

type Level int
const (
	LevelM Level = 0b0
	LevelH Level = 0b1
)

func (Level) IsValid added in v0.1.1

func (lv Level) IsValid() bool

IsValid returns true if the level is valid.

func (Level) String

func (lv Level) String() string

type Mode

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

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

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

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

	ModeTerminated Mode = 0b0000
)

func (Mode) String

func (mode Mode) String() string

type Priority

type Priority int

Priority is a priority for selecting the version.

const (
	// PriorityArea selects the version that minimizes the area.
	PriorityArea Priority = iota

	// PriorityHeight selects the version that minimizes the height.
	PriorityHeight

	// PriorityWidth selects the version that minimizes the width.
	PriorityWidth
)

type QRCode

type QRCode struct {
	Version  Version
	Level    Level
	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)

type Segment

type Segment struct {
	Mode Mode
	Data []byte
}

type Version

type Version int
const (
	R7x43   Version = 0b00000
	R7x59   Version = 0b00001
	R7x77   Version = 0b00010
	R7x99   Version = 0b00011
	R7x139  Version = 0b00100
	R9x43   Version = 0b00101
	R9x59   Version = 0b00110
	R9x77   Version = 0b00111
	R9x99   Version = 0b01000
	R9x139  Version = 0b01001
	R11x27  Version = 0b01010
	R11x43  Version = 0b01011
	R11x59  Version = 0b01100
	R11x77  Version = 0b01101
	R11x99  Version = 0b01110
	R11x139 Version = 0b01111
	R13x27  Version = 0b10000
	R13x43  Version = 0b10001
	R13x59  Version = 0b10010
	R13x77  Version = 0b10011
	R13x99  Version = 0b10100
	R13x139 Version = 0b10101
	R15x43  Version = 0b10110
	R15x59  Version = 0b10111
	R15x77  Version = 0b11000
	R15x99  Version = 0b11001
	R15x139 Version = 0b11010
	R17x43  Version = 0b11011
	R17x59  Version = 0b11100
	R17x77  Version = 0b11101
	R17x99  Version = 0b11110
	R17x139 Version = 0b11111
)

func (Version) Height

func (version Version) Height() int

Height returns the width of version.

func (Version) IsValid added in v0.1.1

func (version Version) IsValid() bool

IsValid returns true if the version is valid.

func (Version) String

func (version Version) String() string

func (Version) Width

func (version Version) Width() int

Width returns the width of version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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