Display RAW image in Android

asked 2014-10-03 13:05:30 -0600

I am trying to display an DNG image in my Android app. I tried to convert it to Bitmap but the program crashes. It works when I convert from JPEG. Any ideas?

public void viewDNGfile() {
    // make a mat and draw something
    File root = Environment.getExternalStorageDirectory();
    File file = new File(root, "DCIM/RAW/test.dng");

   Mat img =  loadOpenCvImage(file.getAbsolutePath());

    // convert to bitmap:
    Bitmap bm = Bitmap.createBitmap(img.cols(), img.rows(),Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(img, bm);

    // Draw
    ImageView iv = (ImageView) findViewById(R.id.imageView1);
    iv.setImageBitmap(bm);
}

public static Mat loadOpenCvImage(final String filePath) {
    Mat imgMat = Highgui.imread(filePath, Highgui.CV_LOAD_IMAGE_ANYDEPTH);
    if (imgMat == null) {
        Log.e("error", "error loading file: " + filePath);
    } else {
        Log.d("error", "Ht: " + imgMat.height() + " Width: " + imgMat.width());
      final String outPath = filePath + "_gray.jpg";
       // Log.d("error", outPath);
       // Highgui.imwrite(outPath, imgMat);
    }
    return imgMat;
}
edit retag flag offensive close merge delete