title: ZXing convert Bitmap to BinaryBitmap
body: <p>I am using OpenCV and Zxing, and I'd like to add 2d code scanning.  I have a few types of images that I could send.  Probably the best is Bitmat (the other option is OpenCV Mat).</p>
  <p>It looks like you used to be able to convert like this:</p>
  <pre><code>Bitmap frame = //this is the frame coming in
  
  LuminanceSource source = new RGBLuminanceSource(frame);
  BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
  
  //then I can use reader.decode(bitmap) to decode the BinaryBitmap
  </code></pre>
  <p>However, RGBLuminaceSource looks like it no longer takes a bitmap as an input.  So how else can I convert an input image to BinaryBitmap???</p>
  <h1>Edit:</h1>
  <p>Ok so I believe I've made some progress, but I'm still having an issue.  I think I have the code that converts the Bitmap into the correct format, however I am now getting an arrayIndexOutOfBounds</p>
  <pre><code>public void zxing(){
      Bitmap bMap = Bitmap.createBitmap(frame.width(), frame.height(), Bitmap.Config.ARGB_8888);
      Utils.matToBitmap(frame, bMap);
      byte[] array = BitmapToArray(bMap);
      LuminanceSource source = new PlanarYUVLuminanceSource(array, bMap.getWidth(), bMap.getHeight(), 0, 0, bMap.getWidth(), bMap.getHeight(), false);
          
      BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
      Reader reader = new DataMatrixReader();
      String sResult = &quot;&quot;;
      try {
          Result result = reader.decode(bitmap);
          sResult = result.getText();
          Log.i(&quot;Result&quot;, sResult);
          }
      catch (NotFoundException e) {
              Log.d(TAG, &quot;Code Not Found&quot;);
              e.printStackTrace();
      }
  }
  
  public byte[] BitmapToArray(Bitmap bmp){
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      bmp.compress(Bitmap.CompressFormat.JPEG, 50, stream);
      byte[] byteArray = stream.toByteArray();
      return byteArray;
  }
  </code></pre>
  <p>I get the error</p>
  <pre><code>02-14 10:19:27.469: E/AndroidRuntime(29736): java.lang.ArrayIndexOutOfBoundsException: length=33341; index=34560 02-14 10:19:27.469: E/AndroidRuntime(29736):   at 
  com.google.zxing.common.HybridBinarizer.calculateBlackPoints(HybridBinarizer.java:199)
  </code></pre>
  <p>I have logged the size of the byte[], and it is the length shown above.  I cant figure out why zxing is expecting it to be bigger</p>