question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MatrixToImageWriter(int ARGOncolor,int ARGOffcolor) not changing colour of the barcode

See original GitHub issue

Bug Reports

I was using this function to create a colorful barcode but the output was plain black& white barcode.
This is the part where I used a function I created RGB which takes 2 integers (red,green,blue values) as parameter & returns an ARGB int value to work with. The code was working till last night but I don’t know for some reason it’s not working now.
BitMatrix matrix = writer.encode(text, BarcodeFormat.CODE_128, 500, 300); MatrixToImageConfig conf = new MatrixToImageConfig(RGB(0,0,255),RGB(0,255,0)); BufferedImage qrcode = MatrixToImageWriter.toBufferedImage(matrix, conf); File outputfile = new File(path); ImageIO.write(qrcode, "png", outputfile);

Here’s the declaration of the RGB function:- private static int RGB(int red,int green,int blue) { int rgb=(65536*red+256*green+blue); return ((16777215-rgb)*(-1)); }

Here’s the resultant barcode128 image New2

And here’s the console output:- On Color = -16776960 Off Color = -16711935

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
DarkMortalcommented, Jun 13, 2021

It’s working now. Thanks a lot man. You’re a lifesaver

1reaction
srowencommented, Jun 13, 2021

Works fine for me. Are you sure you’re reading the right path? Ex:

    Code128Writer writer = new Code128Writer();
    BitMatrix matrix = writer.encode("foobar", BarcodeFormat.CODE_128, 500, 300);
    MatrixToImageConfig conf = new MatrixToImageConfig(0xFF00FF00, 0xFF0000FF);
    BufferedImage qrcode = MatrixToImageWriter.toBufferedImage(matrix, conf);
    File outputfile = new File("/tmp/out.png");
    ImageIO.write(qrcode, "png", outputfile);

out

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are my jpeg QR codes from ZXing not black and white?
A correct looking QR code image is created but instead of being black and white the "white" part is a peach color and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found