Skip to content

Instantly share code, notes, and snippets.

@slashthinking
Created February 3, 2013 14:14
Show Gist options
  • Save slashthinking/4701959 to your computer and use it in GitHub Desktop.
Save slashthinking/4701959 to your computer and use it in GitHub Desktop.
qq源码中的获取屏幕截屏的代码,很有意思。
public static Bitmap screenshot(Context paramContext)
{
boolean bool = sLoadSO;
Bitmap localBitmap = null;
if (bool);
try
{
byte[] arrayOfByte = getFrameBuffer();
localBitmap = null;
if (arrayOfByte == null)
{
Process localProcess = Runtime.getRuntime().exec("su");
DataOutputStream localDataOutputStream = new DataOutputStream(localProcess.getOutputStream());
localDataOutputStream.writeBytes("chmod 666 /dev/graphics/fb0\n");
localDataOutputStream.writeBytes("exit\n");
localDataOutputStream.flush();
new Thread(localProcess)
{
public void run()
{
try
{
NativeUtil.this.waitFor();
return;
}
catch (InterruptedException localInterruptedException)
{
while (true)
localInterruptedException.printStackTrace();
}
}
}
.start();
arrayOfByte = getFrameBuffer();
}
localBitmap = null;
if (arrayOfByte != null)
{
ByteBuffer localByteBuffer = ByteBuffer.wrap(arrayOfByte);
localBitmap = Bitmap.createBitmap(paramContext.getResources().getDisplayMetrics().widthPixels, paramContext.getResources().getDisplayMetrics().heightPixels, Bitmap.Config.ARGB_8888);
localBitmap.copyPixelsFromBuffer(localByteBuffer);
}
return localBitmap;
}
catch (Exception localException)
{
while (true)
localException.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment