首页 新闻 搜索 专区 学院

Android截屏

0
[已解决问题] 解决于 2013-07-24 17:33

Android如何实现VideoView的截屏

我用正常的截屏方法,出现黑屏问题,求解决!!!!

yangxiaoboyan的主页 yangxiaoboyan | 菜鸟二级 | 园豆:224
提问于:2013-07-22 14:07
< >
分享
最佳答案
0

获取屏幕Bitmap:

// 获取屏幕大小:   DisplayMetrics metrics = new DisplayMetrics();   WindowManager WM = (WindowManager) activity     .getSystemService(Context.WINDOW_SERVICE);   Display display = WM.getDefaultDisplay();   display.getMetrics(metrics);   int height = metrics.heightPixels; // 屏幕高   int width = metrics.widthPixels; // 屏幕的宽   // 获取显示方式   int pixelformat = display.getPixelFormat();   PixelFormat localPixelFormat1 = new PixelFormat();   PixelFormat.getPixelFormatInfo(pixelformat, localPixelFormat1);   int deepth = localPixelFormat1.bytesPerPixel;// 位深   byte[] piex = new byte[height * width * deepth];

  InputStream stream = getInput();//获取fb0输入数据流   DataInputStream dStream = new DataInputStream(stream);   dStream.readFully(piex);   // 保存图片   int[] colors = new int[height * width];   for (int m = 0; m < colors.length; m++) {    int b = (piex[m * 4] & 0xFF);    int g = (piex[m * 4 + 1] & 0xFF);    int r = (piex[m * 4 + 2] & 0xFF);    int a = (piex[m * 4 + 3] & 0xFF);    colors[m] = (a << 24) + (r << 16) + (g << 8) + b;   }   // piex生成Bitmap   Bitmap bitmap = Bitmap.createBitmap(colors, width, height,     Bitmap.Config.ARGB_8888);

yangxiaoboyan | 菜鸟二级 |园豆:224 | 2013-07-24 17:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册