when i capture screenshot of target image , scanning pocess gets slow down , is there any solution to speed up the scanning process along with caturing screenshot
and i have usedx below methods.
public void onDrawFrame(GL10 gl) { if (!mIsActive) { return; } int w = mScreenWidth; int h = mScreenHeight;
// if ( some_condition ) { saveScreenShot(0, 0, w, h, "test.png"); // } renderFrame(); }
public void saveScreenShot(int x, int y, int w, int h, String filename) { Bitmap bmp = grabPixels(x, y, w, h); System.out.println("bitmapbmpbmpbmpbmp : " + bmp); try { String path = Environment.getExternalStorageDirectory() + "/" + filename; DebugLog.LOGD(path, "snaaapppp"); File file = new File(path); file.createNewFile(); FileOutputStream fos = new FileOutputStream(file); bmp.compress(CompressFormat.PNG, 100, fos); fos.flush(); fos.close(); } catch (Exception e) { DebugLog.LOGD(e.getStackTrace().toString(), "aaaa"); } } public Bitmap grabPixels(int x, int y, int w, int h) { int b[] = new int[w * (y + h)]; int bt[] = new int[w * h]; IntBuffer ib = IntBuffer.wrap(b); ib.position(0); GLES20.glReadPixels(x, 0, w, y + h, GLES20.GL_RGBA, GLES20.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) & 0x00ff0000; int pix1 = (pix & 0xff00ff00) | pr | pb; bt[(h - k - 1) * w + j] = pix1; } } Bitmap sb = Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888); return sb; }
Please give me suggestion to improve my scanning speed