pdfcode.go 717 B

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