Android利用SurfaceView中显示视频通话时,截屏总是黑屏,怎么破?

#NullPoint# 2016-07-16 02:03:48
在网上也找了大量帖子了,大都是静态截图,对视频流的截图,实在不知道怎么实现(=@__@=),走过路过的大神,可以给点指导!!!

...全文
768 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
留白的云 2017-08-03
  • 打赏
  • 举报
回复
引用 5 楼 fancy_T 的回复:
楼主解决了吗?可以分享下解决方案吗?
如果设备root过的话,看这个帖子可以直接掉adb命令截图。我的成功了。 http://blog.csdn.net/xuan521521/article/details/51136718
fancy_T 2017-07-11
  • 打赏
  • 举报
回复
楼主解决了吗?可以分享下解决方案吗?
Aln_ 2016-07-16
  • 打赏
  • 举报
回复
// Lock canvas if (bitmap != null && mSurfaceHolder != null) { Canvas canvas = mSurfaceHolder.lockCanvas(); bp = bitmap ; // Draw the bitmap to the canvas if (canvas != null) { canvas.drawBitmap(bitmap, 0, 0, null); // Post the canvas for displaying mSurfaceHolder.unlockCanvasAndPost(canvas); } 这是我 以前的 视频 截图 就在canvas 绘制时 获取 保存,再在 下面做一些保存本地的处理
Aln_ 2016-07-16
  • 打赏
  • 举报
回复
引用 2 楼 crash163 的回复:
试下这段代码行不行:

import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.opengles.GL10;

// in code.
public static void screenShot()
{
//xxxxx
EGL10 egl = (EGL10)EGLContext.getEGL(); 
GL10 gl = (GL10)egl.eglGetCurrentContext().getGL();
Bitmap bp = SavePixels(0, 0, 宽, 高, gl)
//xxx
}

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)&0x00ff0000;
               int pix1=(pix&0xff00ff00) | pr | pb;
               bt[(h-k-1)*w+j]=pix1;
          }
     }


     Bitmap bp=Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888);
     return bp;
}
或者参考https://github.com/google/grafika/blob/master/src/com/android/grafika/gles/EglSurfaceBase.java中的方法saveFrame ///
这个是opengl 绘制视频的截图
网易云捕 2016-07-16
  • 打赏
  • 举报
回复
试下这段代码行不行:

import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.opengles.GL10;

// in code.
public static void screenShot()
{
//xxxxx
EGL10 egl = (EGL10)EGLContext.getEGL(); 
GL10 gl = (GL10)egl.eglGetCurrentContext().getGL();
Bitmap bp = SavePixels(0, 0, 宽, 高, gl)
//xxx
}

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)&0x00ff0000;
               int pix1=(pix&0xff00ff00) | pr | pb;
               bt[(h-k-1)*w+j]=pix1;
          }
     }


     Bitmap bp=Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888);
     return bp;
}
或者参考https://github.com/google/grafika/blob/master/src/com/android/grafika/gles/EglSurfaceBase.java中的方法saveFrame ///
#NullPoint# 2016-07-16
  • 打赏
  • 举报
回复
求不沉

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧