简体   繁体   中英

How to convert .raw file to image file in android rooted device programmatically

I am trying to create a screenshot capturing app in android which capture screen shot of device screen by using adb command programmatically. I have tried every link from stack overflow and other sites but not much successful yet. can any body help me out here. I have followed this link Android take screenshot on rooted device to create the .raw file but now i am stuck on how to convert raw file to image in android.

if raw is image file then u can change extentention to jpg or png,

File ss = new File(ssDir, "ss.raw");

change this to

   File ss = new File(ssDir, "ss.jpg");

but capturing screenshots require root permission to execute su permission

 File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "screeshot.jpg");
Process localProcess  = Runtime.getRuntime().exec("su");
OutputStream  os = localProcess .getOutputStream();
 //DataOutputStream  dos = (DataOutputStream) localProcess.getOutputStream();
os.write(("/system/bin/screencap -p " + f.toString()).getBytes("ASCII"));
//dos.writeBytes("exit\n");
os.flush();
os.close();
localProcess .waitFor();

Android cannot do that by itself. You need a external decoder. There are libraries which can decode, demosaicing, whitebalance etc and convert to RGB. This is a digital negative and needs a lot of image processing before its viewable in Android.

Check out dcraw, its a library for decoding all types of RAW-files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM