Created
February 3, 2013 14:14
-
-
Save slashthinking/4701959 to your computer and use it in GitHub Desktop.
qq源码中的获取屏幕截屏的代码,很有意思。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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