...
1 package pdf417
2
3 import (
4 "image"
5 "image/color"
6
7 "github.com/boombuler/barcode"
8 "github.com/boombuler/barcode/utils"
9 )
10
11 type pdfBarcode struct {
12 data string
13 width int
14 code *utils.BitList
15 }
16
17 func (c *pdfBarcode) Metadata() barcode.Metadata {
18 return barcode.Metadata{barcode.TypePDF, 2}
19 }
20
21 func (c *pdfBarcode) Content() string {
22 return c.data
23 }
24
25 func (c *pdfBarcode) ColorModel() color.Model {
26 return color.Gray16Model
27 }
28
29 func (c *pdfBarcode) Bounds() image.Rectangle {
30 height := c.code.Len() / c.width
31
32 return image.Rect(0, 0, c.width, height*moduleHeight)
33 }
34
35 func (c *pdfBarcode) At(x, y int) color.Color {
36 if c.code.GetBit((y/moduleHeight)*c.width + x) {
37 return color.Black
38 }
39 return color.White
40 }
41
View as plain text