qr

package
v0.0.0-...-25e8c23 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLogoSize = 0.3
)
View Source
const DefaultQuality = 75

DefaultQuality is the default quality encoding parameter.

Variables

This section is empty.

Functions

func JPEGEncode

func JPEGEncode(w io.Writer, m *mat2d, o *Options) error

JPEGEncode writes the Image m to w in JPEG 4:2:0 baseline format with the given options. Default parameters are used if a nil *Options is passed.

func WithAlphaBlending

func WithAlphaBlending(c *config)

func WithLogoSize

func WithLogoSize(logoSize float64) func(c *config)

Types

type CompressionLevel

type CompressionLevel int

CompressionLevel indicates the compression level.

const (
	DefaultCompression CompressionLevel = 0
	NoCompression      CompressionLevel = -1
	BestSpeed          CompressionLevel = -2
	BestCompression    CompressionLevel = -3
)

type EncoderBuffer

type EncoderBuffer pngEncoder

EncoderBuffer holds the buffers used for encoding PNG images.

type EncoderBufferPool

type EncoderBufferPool interface {
	Get() *EncoderBuffer
	Put(*EncoderBuffer)
}

EncoderBufferPool is an interface for getting and returning temporary instances of the EncoderBuffer struct. This can be used to reuse buffers when encoding multiple images.

type ErrEncodingJPEG

type ErrEncodingJPEG struct {
	Err error
}

func (*ErrEncodingJPEG) Error

func (e *ErrEncodingJPEG) Error() string

type ErrEncodingPNG

type ErrEncodingPNG struct {
	Err error
}

func (*ErrEncodingPNG) Error

func (e *ErrEncodingPNG) Error() string

type ErrEncodingSVG

type ErrEncodingSVG struct {
	Err error
}

func (*ErrEncodingSVG) Error

func (e *ErrEncodingSVG) Error() string

type ErrFailedToCreateQRCode

type ErrFailedToCreateQRCode struct {
	Err error
}

func (*ErrFailedToCreateQRCode) Error

func (e *ErrFailedToCreateQRCode) Error() string

type Generator

type Generator interface {
	GenerateQRCode(content string, size int, margin int, outputFormat OutputFormat, opts ...options) (io.WriterTo, error)
}

func NewGenerator

func NewGenerator(idealQRLogo image.Image, maxCacheSizeInBytes int64) Generator

NewGenerator will create a new generator that creates iDEAL-qr qr-codes. The given image is the iDEAL logo. This image is converted into a *mat2d data-structure to efficiently overlay the logo on top off the QR-code. If maxCacheSizeInBytes is smaller than (minCacheSize = 20000000), the minCacheSize is used instead.

type InputMatrix

type InputMatrix interface {
	GetWidth() int
	GetHeight() int
	Get(int, int) bool
}

type Options

type Options struct {
	Quality int
}

Options are the encoding parameters. Quality ranges from 1 to 100 inclusive, higher is better.

type OutputFormat

type OutputFormat string
const (
	PNG OutputFormat = "png"
	JPG OutputFormat = "jpg"
	SVG OutputFormat = "svg"
)

type PNGEncoder

type PNGEncoder struct {
	CompressionLevel CompressionLevel

	// BufferPool optionally specifies a buffer pool to get temporary
	// EncoderBuffers when encoding an image.
	BufferPool EncoderBufferPool
}

PNGEncoder configures encoding PNG images.

func (*PNGEncoder) Encode

func (enc *PNGEncoder) Encode(w io.Writer, m *mat2d) error

Encode writes the Image(*mat2d) m to w in PNG format.

type Rect

type Rect struct {
	X1, Y1, X2, Y2 int
}

Rect describes a rectangle where (X1, Y2) is the upper-left corner and (X2, Y2) is the lower-right corner

func FindRects

func FindRects(m InputMatrix) []Rect

FindRects takes an InputMatrix and returns a slice of rectangles found in the given input

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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