barcode/pdf417/pdfcode.go

42 lines
754 B
Go
Raw Normal View History

2017-06-04 18:06:35 +00:00
package pdf417
import (
"image"
"image/color"
"github.com/boombuler/barcode"
"github.com/boombuler/barcode/utils"
)
type pdfBarcode struct {
data string
width int
code *utils.BitList
color barcode.ColorScheme
2017-06-04 18:06:35 +00:00
}
func (c *pdfBarcode) Metadata() barcode.Metadata {
2017-06-17 21:42:17 +00:00
return barcode.Metadata{barcode.TypePDF, 2}
2017-06-04 18:06:35 +00:00
}
func (c *pdfBarcode) Content() string {
return c.data
}
func (c *pdfBarcode) ColorModel() color.Model {
return c.color.Model
2017-06-04 18:06:35 +00:00
}
func (c *pdfBarcode) Bounds() image.Rectangle {
height := c.code.Len() / c.width
return image.Rect(0, 0, c.width, height*moduleHeight)
}
func (c *pdfBarcode) At(x, y int) color.Color {
if c.code.GetBit((y/moduleHeight)*c.width + x) {
return c.color.Foreground
2017-06-04 18:06:35 +00:00
}
return c.color.Background
2017-06-04 18:06:35 +00:00
}