Documentation ¶
Index ¶
- func Encode(content string, level RecoveryLevel, size int) ([]byte, error)
- func WriteColorFile(content string, level RecoveryLevel, size int, ...) error
- func WriteFile(content string, level RecoveryLevel, size int, filename string) error
- type QRCode
- func (q *QRCode) Bitmap() [][]bool
- func (q *QRCode) Image(size int) image.Image
- func (q *QRCode) PNG(size int) ([]byte, error)
- func (q *QRCode) ToSmallString(inverseColor bool) string
- func (q *QRCode) ToString(inverseColor bool) string
- func (q *QRCode) Write(size int, out io.Writer) error
- func (q *QRCode) WriteFile(size int, filename string) error
- type RecoveryLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
func Encode(content string, level RecoveryLevel, size int) ([]byte, error)
Encode a QR Code and return a raw PNG image Size is both the image width and height in pixels If size is too small then a larger image is silently returned Negative values for size cause a variable sized image to be returned: See the documentation for Image() To serve over HTTP, remember to send a Content-Type: image/png header
func WriteColorFile ¶
func WriteColorFile(content string, level RecoveryLevel, size int, background, foreground color.Color, filename string) error
Encodes, then writes a QR Code to the given filename in PNG format Allows you to specify the colors you want to use Size is both the image width and height in pixels If size is too small then a larger image is silently written Negative values for size cause a variable sized image to be written: See the documentation for Image()
func WriteFile ¶
func WriteFile(content string, level RecoveryLevel, size int, filename string) error
Encodes, then writes a QR Code to the given filename in PNG format Size is both the image width and height in pixels If size is too small then a larger image is silently written Negative values for size cause a variable sized image to be written: See the documentation for Image()
Types ¶
type QRCode ¶
type QRCode struct { Content string // Original content encoded Level RecoveryLevel // QR Code type VersionNumber int BackgroundColor color.Color // User settable drawing options ForegroundColor color.Color DisableBorder bool // Disable the QR Code border Border bool // QR Code border. True — borders are enabled // contains filtered or unexported fields }
func New ¶
func New(content string, level RecoveryLevel) (*QRCode, error)
Constructs a QR Code. An error occurs if the content is too long
func NewWithForcedVersion ¶
func NewWithForcedVersion(content string, version int, level RecoveryLevel) (*QRCode, error)
Constructs a QR code of a specific version. An error occurs in case of invalid version
func (*QRCode) Bitmap ¶
Returns the QR Code as a 2D array of 1-bit pixels bitmap[y][x] is true if the pixel at (x, y) is set The bitmap includes the required "quiet zone" around the QR Code to aid decoding.
func (*QRCode) Image ¶
Returns the QR Code as an image.Image A positive size sets a fixed image width and height (e.g. 256 yields an 256x256px image) Depending on the amount of data encoded, fixed size images can have different amounts of padding (white space around the QR Code) As an alternative, a variable sized image can be generated instead: A negative size causes a variable sized image to be returned The image returned is the minimum size required for the QR Code. Choose a larger negative number to increase the scale of the image e.g. a size of -5 causes each module (QR Code "pixel") to be 5px in size
func (*QRCode) PNG ¶
Returns the QR Code as a PNG image Size is both the image width and height in pixels If size is too small then a larger image is silently returned Negative values for size cause a variable sized image to be returned: See the documentation for Image()
func (*QRCode) ToSmallString ¶
Produces a multi-line string that forms a QR-code image, a factor two smaller in x and y then ToString
func (*QRCode) Write ¶
Writes the QR Code as a PNG image to io.Writer size is both the image width and height in pixels If size is too small then a larger image is silently written Negative values for size cause a variable sized image to be written: See the documentation for Image()
type RecoveryLevel ¶
type RecoveryLevel int
const ( Low RecoveryLevel = iota // Level L: 7% error recovery Medium // Level M: 15% error recovery. Good default choice High // Level Q: 25% error recovery Highest // Level H: 30% error recovery )