DisplayMetrics metrics = new DisplayMetrics();
WindowManager WM = getWindowManager();
Display display = WM.getDefaultDisplay();
display.getMetrics(metrics);
int height = metrics.heightPixels; // 屏幕高
int with = metrics.widthPixels; // 屏幕的宽// 获取显示方式
int pixelformat = display.getPixelFormat();
PixelFormat localPixelFormat1 = new PixelFormat();
PixelFormat.getPixelFormatInfo(pixelformat, localPixelFormat1);
int deepth = localPixelFormat1.bytesPerPixel;// 位深
byte[] piex = new byte[height * with * deepth];// File file = new File("/dev/graphics/fb0");// 添加root 权限
try {
Runtime.getRuntime().exec("chmod 777 /dev/graphics/fb0");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return;
}Runtime runtime = Runtime.getRuntime();
String s1 = "cat /dev/graphics/fb0";
java.lang.Process process;
try {
process = runtime.exec(s1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}stream = process.getInputStream();
// } catch (FileNotFoundException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
// }DataInputStream dStream = new DataInputStream(stream);
try {
dStream.readFully(piex);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}// Bitmap bitmap = Bitmap.createBitmap( piex, with, height,
// Config.ARGB_8888 );try {
FileOutputStream out = new FileOutputStream(
"/mnt/sdcard/screen.jpg");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// bitmap.compress( Bitmap.CompressFormat.JPEG, 100, out );framebufferbitmap