goqr

package module
v0.0.0-...-a2b125f Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2014 License: MIT Imports: 6 Imported by: 0

README

goqr

goqr - a QRcode generator written in Go.

Install

goqr is available at github.com. Get it by running.

$ go get github.com/kiktomo/goqr
Sample code
package main

import (
    "github.com/kiktomo/goqr"
    "image/png"
    "os"
)

func main() {

    // "0123456789" -> Numeric mode
    // "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:" -> Alphanumeric mode
    // "HELLO WORLD" -> Alphanumeric mode (upper-case only)
    // "Hello world" -> 8BitByte mode
    txt := "HELLO WORLD"

    // QRcode version:7
    // version := 0 (Auto)
    version := 7

    // QRcode error correction level: "M"
    // eclevel := 0 (Auto)
    eclevel := goqr.ECLevelM

    // Encode() returns image.Image
    qr, err := goqr.Encode(txt, version, eclevel)
    if err != nil {
        return
    }

    // png file output
    f, _ := os.Create("./qrcode.png")
    defer f.Close()
    png.Encode(f, qr)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(data string, version int, level ECLevel) (image.Image, error)

Types

type ECLevel

type ECLevel int
const (
	ECLevelL ECLevel = 1 << iota
	ECLevelM ECLevel = 1 << iota
	ECLevelQ ECLevel = 1 << iota
	ECLevelH ECLevel = 1 << iota
)

type Qrcode

type Qrcode struct {
	Version int     // qrcode version 1-40 (0:auto)
	Level   ECLevel // error correction Level (0:auto)

	ModuleSize     int // module size (default 1)
	QuietZoneWidth int // quiet zone width
	// contains filtered or unexported fields
}

func (*Qrcode) Encode

func (qr *Qrcode) Encode() (image.Image, error)

Jump to

Keyboard shortcuts

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