title: Correct way to convert between Bitmap and Mat in OpenCV on Android?
body: <p>I'm currently trying to migrate a bit of legacy code from iPhone to Android. This code uses the OpenCV library to do some image processing.
  And I cannot understand how to do the conversion between Mat and Android Bitmap classes. </p>
  
  <p>This code shows a very simplified example which loads a bitmap into a Mat, then converts it back to Bitmap. The resulting image looks weird - it's filled with blue and white pixels. And the original is a normal PNG image... </p>
  
  <pre><code>  Mat img = Utils.loadResource(context, resId);
    Bitmap tmp = Bitmap.createBitmap(img.rows(), img.cols(),  
    Bitmap.Config.ARGB_8888);               
    Utils.matToBitmap(img, tmp);
  </code></pre>