COCOS 2D screen shot is black in Android

瘦欲@ 提交于 2019-11-30 11:50:49
jeet

Just change SavePixelx method to the below:

public static Bitmap SavePixels(int x, int y, int w, int h, GL10 gl)
{  
     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++)
     {
          //remember, that OpenGL bitmap is incompatible with Android bitmap
          //and so, some correction need.        
          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 sb = Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888); 
    return sb;
}
androiddeveloper2011

just try to change GL10.GL_RGB or make changes in bitmap.config . It might be work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!