output

package
v0.0.0-...-6b448be Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JPG Type = iota // 0
	PNG             // 1
	GIF             // 2
	SVG             // 3

	// AUTO_SIZE : set auto size for qrcode , per module fill by 4 pixels
	AUTO_SIZE = 0

	LogoOptionName OptionName = "logo"
)

defined OutputType constants

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseOutput

type BaseOutput struct {
	// image type
	Type Type
	// image width/height
	Size    int
	Options []*Option
	// contains filtered or unexported fields
}

func (*BaseOutput) AddOption

func (out *BaseOutput) AddOption(options ...*Option)

func (*BaseOutput) EvalMicroQRCodePenalty

func (out *BaseOutput) EvalMicroQRCodePenalty(moduleSize int) uint

EvalMicroQRCodePenalty :Evaluate Penalty for Micro QRCode. Page 62, 7.8.3.2 Evaluation of Micro QRCode Symbols. if SUM1 <= SUM2

Evaluation Score = SUM1 x 16 + SUM2

if SUM1 > SUM2

Evaluation Score = SUM2 x 16 + SUM2

where:

SUM1 number of dark modules in right side edge
SUM2 number of dark modules in lower side edge

func (*BaseOutput) EvalPenalty

func (out *BaseOutput) EvalPenalty(moduleSize int) uint

EvalPenalty :Evaluate Penalty for QRCode. param: moduleSize, not contains quiet zone size.

func (*BaseOutput) GetModule

func (out *BaseOutput) GetModule(x int, y int) bool

func (*BaseOutput) GetRecommendSize

func (out *BaseOutput) GetRecommendSize(moduleSize int) []int

GetRecommendSize :Get recommend size for QRCode return: the array of two recommend sizes

func (*BaseOutput) IsModuleSet

func (out *BaseOutput) IsModuleSet(x int, y int) bool

type ImageOutput

type ImageOutput struct {
	*BaseOutput
	// contains filtered or unexported fields
}

func NewGIFOutput

func NewGIFOutput(size int) *ImageOutput

func NewGIFOutput0

func NewGIFOutput0() *ImageOutput

NewGIFOutput0 :Output a new GIF image by auto size.

func NewJPGOutput

func NewJPGOutput(size int) *ImageOutput

func NewJPGOutput0

func NewJPGOutput0() *ImageOutput

NewJPGOutput0 :Output a new JPG image by auto size.

func NewPNGOutput

func NewPNGOutput(size int) *ImageOutput

func NewPNGOutput0

func NewPNGOutput0() *ImageOutput

NewPNGOutput0 :Output a new PNG image by auto size.

func (*ImageOutput) Clone

func (out *ImageOutput) Clone() Output

Clone : Shallow copy BaseOutput and modules from output, init new image instance

func (*ImageOutput) GetBaseOutput

func (out *ImageOutput) GetBaseOutput() *BaseOutput

func (*ImageOutput) GetImage

func (out *ImageOutput) GetImage() *image.NRGBA

func (*ImageOutput) GetModule

func (out *ImageOutput) GetModule(x int, y int) bool

func (*ImageOutput) Init

func (out *ImageOutput) Init(version *model.Version, qz *model.QuietZone)

Init :init for output when size is AUTO_SIZE

func (*ImageOutput) IsModuleSet

func (out *ImageOutput) IsModuleSet(x int, y int) bool

func (*ImageOutput) ResizeToFit

func (out *ImageOutput) ResizeToFit(moduleSize int, quietZoneSize int, pixelSize int)

func (*ImageOutput) Save

func (out *ImageOutput) Save(fileName string) error

Save : save file

func (*ImageOutput) SaveToBase64

func (out *ImageOutput) SaveToBase64() (base64Str string, err error)

func (*ImageOutput) Write

func (out *ImageOutput) Write(x int, y int, black bool)

Write : write data

func (*ImageOutput) WriteModule

func (out *ImageOutput) WriteModule(x int, y int, black bool, pixelSize int)

WriteModule : write data

func (*ImageOutput) WriteModuleColor

func (out *ImageOutput) WriteModuleColor(x int, y int, dark bool, setColor color.Color, pixelSize int)

type Option

type Option struct {
	Name  OptionName
	Value string
}

Option : Output Option

func LogoOption

func LogoOption(logoImage string) *Option

LogoOption : Option for add logo image at center of QRCode

type OptionName

type OptionName = string

type Output

type Output interface {
	GetBaseOutput() *BaseOutput
	// Init :init for output when size is AUTO_SIZE
	Init(version *model.Version, qz *model.QuietZone)
	Write(x int, y int, black bool)
	// WriteModule :write per module by pixelSize
	WriteModule(x int, y int, black bool, pixelSize int)
	WriteModuleColor(x int, y int, dark bool, setColor color.Color, pixelSize int)
	// IsModuleSet : check the module whether or not be set
	IsModuleSet(x int, y int) bool
	// GetModule : x,y is module axes , not pixel axes.
	GetModule(x int, y int) bool
	GetImage() *image.NRGBA
	Clone() Output
	ResizeToFit(moduleSize int, quietZoneSize int, pixelSize int)
	Save(fileName string) error
	SaveToBase64() (string, error)
}

Output : the output interface for qrcode print

type Type

type Type = int

Jump to

Keyboard shortcuts

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