我目前正在使用下面的方法來創建一個模糊的截圖(它是在另一個線程上發現的解決方案的稍微改變的版本),它的工作原理,但它的生成相當慢,如果使用中游戲,它不是非常有用。任何人都可以提出一個更好的解希望這對其他人也有用。Android上更快的模糊屏幕截圖?
public static Bitmap blurredScreenshot(){
CGSize winSize = CCDirector.sharedDirector().displaySize();
int w = (int) winSize.width;
int h = (int) winSize.height;
int b[] = new int[w * h];
int bt[] = new int[w * h];
IntBuffer ib = IntBuffer.wrap(b);
ib.position(0);
GL10 gl = CCDirector.gl;
gl.glReadPixels(0, 0, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, ib);
for (int i = 0, k = 0; i < h; i++, k++) {
for (int j = 0; j < w; j++) {
int pix = b[i * w + j];
int pb = (pix >> 16) & 0xff;
int pr = (pix << 16) & 0xffff0000;
int pix1 = (pix & 0xff00ff00) | pr | pb;
bt[(h - k - 1) * w + j] = pix1;
}
}
Bitmap bitmap = Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888);
Bitmap scaledSmall = Bitmap.createScaledBitmap(bitmap, (int)w/5, (int)h/5, true);
Bitmap scaledBlur = Bitmap.createScaledBitmap(scaledSmall, w, h, true);
return scaledBlur;
}
Renderscript ?? – Blackbelt 2014-09-12 15:25:26