title: sample code to detect QRCode in an image
body: <p>I use  this code in C# to decode (not detect) a QRCode and it works:</p>
  
  <pre><code>LuminanceSource ls = new RGBLuminanceSource(image, image.Width, image.Height);
  Result result = new QRCodeReader().decode(new BinaryBitmap(new HybridBinarizer(ls)));
  </code></pre>
  
  <p>Now I would like to detect a QRCode in a more complex image with a lot of other stuffs such images and text. I'm not able to understand how to accomplish this because I cannot find any sample and transforming Bitmap (C#) to Bitmatrix for Detector (zxing) is not so direct.</p>
  
  <p>Does anyone have a piece of code to give me?</p>
  
  <p>thanks a lot</p>
  
  <hr>
  
  <h2>UPDATE</h2>
  
  <hr>
  
  <p>I try this code but I get a ReaderException:</p>
  
  <p>The code:</p>
  
  <pre><code>LuminanceSource ls = new RGBLuminanceSource(bitmap, bitmap.Width, bitmap.Height);            
  QRCodeMultiReader multiReader = new QRCodeMultiReader();
  Result[] rs = multiReader.decodeMultiple(new BinaryBitmap(new HybridBinarizer(ls)), hints);
   return rs[0].Text;
  </code></pre>
  
  <p>The exception </p>
  
  <pre><code>com.google.zxing.ReaderException:
  
  in com.google.zxing.qrcode.detector.FinderPatternFinder.selectBestPatterns()
     in com.google.zxing.qrcode.detector.FinderPatternFinder.find(Hashtable hints)
     in com.google.zxing.qrcode.detector.Detector.detect(Hashtable hints)
     in com.google.zxing.qrcode.QRCodeReader.decode(BinaryBitmap image, Hashtable hints)
     in com.google.zxing.qrcode.QRCodeReader.decode(BinaryBitmap image)
     in ...Logic.BarCodeManager.QRCodeReader(Bitmap bitmap) in 
  </code></pre>
  
  <hr>
  
  <h2>UPDATE 02/12/2011</h2>
  
  <hr>
  
  <p>I have just tried to scan the printed QRCode (with the piece of code on the top of the post) with an App on my iPhone and it works well! So the problem is surely in the detection/decode phase.</p>