title: Get ZXing Reader to decode a bitmap
body: <p>I haven't yet been able to decode a QR code with ZXing.  I'm using a BUG from buglabs.net but the problem doesn't seem to have anything to do with the hardware, but rather the format of the image.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>try {
      LuminanceSource source = new AWTImageLuminanceSource(bimage);
      bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
      Hashtable&lt;DecodeHintType, Object&gt; hints = new Hashtable&lt;DecodeHintType, Object&gt;();
      hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
      Result result = reader.decode(bitmap, hints) ;
      System.out.println("result is:" + result.getText());
      } catch (ReaderException re) {
              System.out.println("I can't find a barcode here");
      }
  </code></pre>
  
  <p>The code breaks at reader.decode(bitmap, hints).  I'm getting a NullPointerException with the following trace:</p>
  
  <pre><code>java.lang.NullPointerException
      at qrcoder.QRCoder.shoot(QRCoder.java:152) // this is the camera shoot function
      at qrcoder.QRCoder.buttonEvent(QRCoder.java:89) // press button
      at com.buglabs.bug.input.pub.InputEventProvider.run(InputEventProvider.java:90)
  </code></pre>
  
  <p>Not sure what the InputEventProvider is trying to tell me.</p>
  
  <p>Thanks so much,
  Sara</p>
  
  <p>Not sure how, but Reader was never getting written to.  Finally works by substituting the Reader's own source code back into the function, using Decoder directly instead.</p>
  
  <pre><code>private void shoot() throws IOException, NotFoundException, FormatException,     ChecksumException {
      // take the picture
      Hashtable hints = null;
      DecoderResult decoderResult;
      cameraLED.setLEDFlash(true);
      camera.grabPreview(buf);
      camera.grabPreview(buf);
      cameraLED.setLEDFlash(false);
      InputStream in = new ByteArrayInputStream(camera.grabFull());
      BufferedImage bImageFromConvert = ImageIO.read(in);
      LuminanceSource source = new BufferedImageLuminanceSource(bImageFromConvert);
      BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
      ResultPoint[] points;
  
        final Decoder decoder = new Decoder();
        DetectorResult detectorResult = new Detector(bitmap.getBlackMatrix()).detect(hints);
        decoderResult = decoder.decode(detectorResult.getBits(), hints);
        points = detectorResult.getPoints();
        Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE);
  
      if (result.getText() != null){
          System.out.println("result is:" + result.getText());
          }           
          else {System.out.println("bitmap is null");}     
  
  
      ic.repaint();
  }
  </code></pre>
  
  <p>This works for now, thanks!</p>