내가 시도 :Android : 루팅 된 기기에서 프레임 버퍼 (스크린 샷)를 어떻게 얻을 수 있습니까?
process = Runtime.getRuntime().exec("su -c cat /dev/graphics/fb0 > /sdcard/frame.raw");
process.waitFor();
그러나 그것은 작동하지 않습니다. 내 장치가 루팅 된 것입니다.
루팅 된 액세스가 필요하다는 많은 답변이 있지만 프레임 버퍼를 가져 오는 실제 코드는 없습니다.
또한 glReadPixels()을 시도했지만 운이 없었습니다.
public void TakeScreen() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = dm.heightPixels;
int screenshotSize = width * height;
ByteBuffer bb = ByteBuffer.allocateDirect(screenshotSize * 4);
bb.order(ByteOrder.nativeOrder());
gl.glReadPixels(0, 0, width, height, GL10.GL_RGBA,
GL10.GL_UNSIGNED_BYTE, bb);
int pixelsBuffer[] = new int[screenshotSize];
bb.asIntBuffer().get(pixelsBuffer);
bb = null;
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.RGB_565);
bitmap.setPixels(pixelsBuffer, screenshotSize - width, -width, 0, 0,
width, height);
pixelsBuffer = null;
short sBuffer[] = new short[screenshotSize];
ShortBuffer sb = ShortBuffer.wrap(sBuffer);
bitmap.copyPixelsToBuffer(sb);
for (int i = 0; i < screenshotSize; ++i) {
short v = sBuffer[i];
sBuffer[i] = (short) (((v & 0x1f) << 11) | (v & 0x7e0) | ((v & 0xf800) >> 11));
}
sb.rewind();
bitmap.copyPixelsFromBuffer(sb);
saveBitmap(bitmap, "/screenshots", "capturedImage");
}
결국이 작업을 수행 할 수 있었습니까? 그렇다면 어떻게 공유 할 수 있습니까? – zacsek
http://stackoverflow.com/questions/17304611/android-read-fb0-always-give-me-blackscreen/17331970#17331970을 참조하십시오. – fadden