Skip to content

Implement support for ColorSchemePalette - #94

Open
xobust wants to merge 2 commits into
boombuler:masterfrom
xobust:master
Open

Implement support for ColorSchemePalette#94
xobust wants to merge 2 commits into
boombuler:masterfrom
xobust:master

Conversation

@xobust

@xobust xobust commented Aug 11, 2026

Copy link
Copy Markdown

Implement support for using a palletized color scheme and fetching ColorIndexAt for each barcode type.
This allows the barcodes to be encoded much more efficiently.
Let me know if you think it can be implemented in a better way.

QR code png encode of "1234567890" drops from 1587 bytes to 445 bytes.

goos: darwin
goarch: arm64
pkg: github.com/boombuler/barcode
cpu: Apple M5 Pro
BenchmarkGenerateBarcode/Aztec/gray16-18                     100           2379843 ns/op              1502 png_B          874511 B/op        256 allocs/op
BenchmarkGenerateBarcode/Aztec/palette-18                    100           1781532 ns/op               358.0 png_B        862525 B/op        259 allocs/op
BenchmarkGenerateBarcode/Codabar/gray16-18                   100           2349281 ns/op              1264 png_B          874130 B/op         62 allocs/op
BenchmarkGenerateBarcode/Codabar/palette-18                  100           2288534 ns/op               253.0 png_B        861240 B/op         65 allocs/op
BenchmarkGenerateBarcode/Code128/gray16-18                   100           2325878 ns/op              1294 png_B          865789 B/op         42 allocs/op
BenchmarkGenerateBarcode/Code128/palette-18                  100           2356118 ns/op               297.0 png_B        851184 B/op         44 allocs/op
BenchmarkGenerateBarcode/Code39/gray16-18                    100           2341752 ns/op              1296 png_B          865204 B/op         41 allocs/op
BenchmarkGenerateBarcode/Code39/palette-18                   100           2371470 ns/op               301.0 png_B        850602 B/op         43 allocs/op
BenchmarkGenerateBarcode/Code93/gray16-18                    100           2251762 ns/op              1276 png_B          862421 B/op         37 allocs/op
BenchmarkGenerateBarcode/Code93/palette-18                   100           2314100 ns/op               292.0 png_B        850486 B/op         40 allocs/op
BenchmarkGenerateBarcode/DataMatrix/gray16-18                100           2147183 ns/op              1442 png_B          864426 B/op         88 allocs/op
BenchmarkGenerateBarcode/DataMatrix/palette-18               100           1798497 ns/op               367.0 png_B        852440 B/op         91 allocs/op
BenchmarkGenerateBarcode/EAN/gray16-18                       100           2495031 ns/op              1292 png_B          865198 B/op         40 allocs/op
BenchmarkGenerateBarcode/EAN/palette-18                      100           2362528 ns/op               293.0 png_B        850597 B/op         42 allocs/op
BenchmarkGenerateBarcode/PDF417/gray16-18                    100           2255121 ns/op              1807 png_B          871674 B/op        113 allocs/op
BenchmarkGenerateBarcode/PDF417/palette-18                   100           1992241 ns/op               590.0 png_B        856003 B/op        115 allocs/op
BenchmarkGenerateBarcode/QRCode/gray16-18                    100           2400042 ns/op              1587 png_B          875777 B/op        207 allocs/op
BenchmarkGenerateBarcode/QRCode/palette-18                   100           1934580 ns/op               445.0 png_B        862800 B/op        208 allocs/op
BenchmarkGenerateBarcode/TwoOfFive/gray16-18                 100           2230039 ns/op              1273 png_B          862413 B/op         37 allocs/op
BenchmarkGenerateBarcode/TwoOfFive/palette-18                100           2173614 ns/op               277.0 png_B        849918 B/op         39 allocs/op
PASS
ok      github.com/boombuler/barcode    4.816s
  • Fix newAztecCode to use provided color scheme instead of hardcoded value
  • Implement support for color ColorSchemePalette

Implement support for using a palletized color scheme and fetching ColorIndexAt for each barcode type.
This allows the barcodes to be encocded much more efficiently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant