title: ZXing 2.1: com.google.zxing.NotFoundException
body: <p>I am attempting to get a successful result with the <a href="http://code.google.com/p/zxing/" rel="nofollow noreferrer" title="ZXing">ZXing</a> 2.1 library.  I am using Java 1.6 on Mac OS X 10.7.5.  I am able to encode text but not decode any images.  Rather, all I get are one-line stack traces of <code>com.google.zxing.NotFoundException</code>.</p>
  
  <p>This seems straightforward but I cannot figure out what I am doing wrong.  Here is a simple test to reproduce.  It encodes a couple barcodes to images and then decodes the images from memory:</p>
  
  <pre><code>public class App {
  
      public static void main(String[] args) {
  
          // Try UPC-A.
          try {
              testEncodeDecode(BarcodeFormat.UPC_A, "012345678905");  // Valid UPC-A.
          } catch (Exception e) {
              e.printStackTrace();
          }
  
          // Try EAN-13.
          try {
              testEncodeDecode(BarcodeFormat.EAN_13, "9310779300005");  // Valid EAN-13.
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
      public static void testEncodeDecode(BarcodeFormat barcodeFormat, String text)
          throws WriterException, NotFoundException, ChecksumException, FormatException, IOException {
  
          // Size of buffered image.
          int width = 200;
          int height = 100;
  
          // Encode to buffered image.
          Writer writer = new MultiFormatWriter();
          BitMatrix bitMatrix = writer.encode(text, barcodeFormat, width, height);
          BufferedImage bufferedImage = MatrixToImageWriter.toBufferedImage(bitMatrix);
  
          // Write to disk for debugging.
          String formatName = "png";
          File outputFile = new File(text + "." + formatName);    
          ImageIO.write(bufferedImage, formatName, outputFile);
  
          // Decode from buffered image.
          LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
          BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
          Reader reader = new MultiFormatReader();
          Result result = reader.decode(bitmap);
  
          // Never gets this far!
          System.out.println("result=" + result.getText());
      }
  }
  </code></pre>
  
  <p>Output will simply be</p>
  
  <pre><code>com.google.zxing.NotFoundException
  com.google.zxing.NotFoundException
  </code></pre>
  
  <p>I'm stumped!  Thanks for your help.  Output images are attached for your reference.</p>
  
  <p>UPC-A <img src="https://i.stack.imgur.com/nIolH.png" alt="abc">
  EAN-13 <img src="https://i.stack.imgur.com/w5ozD.png" alt="def"></p>