   Android reading frame buffer using glReadPixels, source code not working
  Hi,I am new to Android development and have an assignment to read frame buffer data after a specified interval of time.I have come up with the following code (this is supposed to read framebuffer and save it as a png to a location), its giving the "application stopped unexpectedly error" on the emulator, and I don't have a physical device:public class mainActivity extends Activity{Bitmap mSavedBM;private EGL10 egl;private EGLDisplay display;private EGLConfig config;private EGLSurface surface;private EGLContext eglContext;private GL11 gl;protected int width, height;//Called when the activity is first created.@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);// get the screen width and heightDisplayMetrics dm = new DisplayMetrics();getWindowManager().getDefaultDisplay().getMetrics(dm);int screenWidth = dm.widthPixels;int screenHeight = dm.heightPixels;String SCREENSHOT_DIR = "/screenshots";initGLFr(); //GlView initialized.savePixels( 0, 10, screenWidth, screenHeight, gl); //this gets the screen to the mSavedBM.saveBitmap(mSavedBM, SCREENSHOT_DIR, "capturedImage");//Now we need to save the bitmap (the screen capture) to some location.setContentView(R.layout.main); //This displays the content on the screen}private void initGLFr(){egl = (EGL10) EGLContext.getEGL();display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);int[] ver = new int[2];egl.eglInitialize(display, ver);int[] configSpec = {EGL10.EGL_NONE};EGLConfig[] configOut = new EGLConfig[1];int[] nConfig = new int[1];egl.eglChooseConfig(display, configSpec, configOut, 1, nConfig);config = configOut[0];eglContext = egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, null);surface = egl.eglCreateWindowSurface(display, config, SurfaceHolder.SURFACE_TYPE_GPU, null);egl.eglMakeCurrent(display, surface, surface, eglContext);gl = (GL11) eglContext.getGL();}public void savePixels(int x, int y, int w, int h, GL10 gl){if (gl == null)return;synchronized (this) {if (mSavedBM != null) {mSavedBM.recycle();mSavedBM = null;}}int b[] = new int[w * (y + h)];int bt[] = new int[w * h];IntBuffer ib = IntBuffer.wrap(b);ib.position(0);gl.glReadPixels(x, 0, w, y + h, GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,ib);for (int i = 0, k = 0; i < h; i++, k++){//OpenGLbitmap is incompatible with Android bitmap//and so, some corrections need to be done.for (int j = 0; j < w; j++){int pix = b;<br>int pb = (pix &gt;&gt; 16) & 0xff;<br>int pr = (pix &lt;&lt; 16) & 0x00ff0000;<br>int pix1 = (pix & 0xff00ff00) | pr | pb;<br>bt[(h - k - 1) * w + j] = pix1;<br>}<br>}<br><br>Bitmap sb = Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888);<br>synchronized (this)<br>{<br>mSavedBM = sb;<br>}<br>}<br><br>static String saveBitmap(Bitmap bitmap, String dir, String baseName) {<br>try {<br>File sdcard = Environment.getExternalStorageDirectory();<br>File pictureDir = new File(sdcard, dir);<br>pictureDir.mkdirs();<br>File f = null;<br>for (int i = 1; i &lt; 200; ++i) {<br>String name = baseName + i + ".png";<br>f = new File(pictureDir, name);<br>if (!f.exists()) {<br>break;<br>}<br>}<br>if (!f.exists()) {<br>String name = f.getAbsolutePath();<br>FileOutputStream fos = new FileOutputStream(name);<br>bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);<br>fos.flush();<br>fos.close();<br>return name;<br>}<br>} catch (Exception e) {<br><br>} finally {<br><br>//if (fos != null) {<br>// fos.close();<br>// }<br><br>}<br>return null;<br>}<br><br>Also, if some &#111;ne can direct me to better way to read the framebuffer it would be great. I am using Android 2.2 and virtual device of API level 8. I have gone through many previous discussions and have found that we can not know read frame buffer directly throuh the "/dev/graphics/fb0".<br><br>Thanks,<br>zorcad
  problem solved, thanks for viewing.   