MatrixToImageWriter(int ARGOncolor,int ARGOffcolor) not changing colour of the barcode
See original GitHub issueBug 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
And here’s the console output:-
On Color = -16776960
Off Color = -16711935
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top GitHub Comments
It’s working now. Thanks a lot man. You’re a lifesaver
Works fine for me. Are you sure you’re reading the right path? Ex: