I have a jpeg file which has 2D bar code. Image resolution is 1593X1212. I am using xing library to decode this barcode from image. I got following code on net.
try {
String a = textField_1.getText(); //my image path
InputStream barCodeInputStream = new FileInputStream(""+a);
BufferedImage barCodeBufferedImage = ImageIO.read(barCodeInputStream);
LuminanceSource source = new BufferedImageLuminanceSource(barCodeBufferedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
MultiFormatReader reader = new MultiFormatReader();
com.google.zxing.Result result = reader.decode(bitmap);
System.out.println("Barcode text is " + result.getText());
textField.setText(""+result.getText());
} catch (Exception e) {
// TODO: handle exception
JOptionPane.showMessageDialog(null, "This image does not contain barcode", "Warning", JOptionPane.WARNING_MESSAGE);
e.printStackTrace();
}