Documentation ¶
Index ¶
- Constants
- func JPEGEncode(w io.Writer, m *mat2d, o *Options) error
- func WithAlphaBlending(c *config)
- func WithLogoSize(logoSize float64) func(c *config)
- type CompressionLevel
- type EncoderBuffer
- type EncoderBufferPool
- type ErrEncodingJPEG
- type ErrEncodingPNG
- type ErrEncodingSVG
- type ErrFailedToCreateQRCode
- type Generator
- type InputMatrix
- type Options
- type OutputFormat
- type PNGEncoder
- type Rect
Constants ¶
const (
DefaultLogoSize = 0.3
)
const DefaultQuality = 75
DefaultQuality is the default quality encoding parameter.
Variables ¶
This section is empty.
Functions ¶
func JPEGEncode ¶
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 ¶
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 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.
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