Android Screen capturing or make video from images

前端 未结 3 693
小蘑菇
小蘑菇 2020-12-16 07:31

I want to make video of my android screen(what i am doing on the android screen) programatically.

Is there any best tutorial or help regarding this. I have searched

相关标签:
3条回答
  • 2020-12-16 07:56

    you can use following code for screen capturing in Android.

    ImageView v1 = (ImageView)findViewById(R.id.mImage);
    v1.setDrawingCacheEnabled(true);
    Bitmap bm = v1.getDrawingCache();
    

    For Creating Video from Images visit this link.

    0 讨论(0)
  • 2020-12-16 07:59

    As long as you have bitmaps you can flip it into video using JCodec ( http://jcodec.org ).

    Here's a sample image sequence encoder: https://github.com/jcodec/jcodec/blob/master/src/main/java/org/jcodec/api/SequenceEncoder.java . You can modify it for your purposes by replacing BufferedImage with Bitmap.

    Use these helper methods:

    public static Picture fromBitmap(Bitmap src) {
      Picture dst = Picture.create((int)src.getWidth(), (int)src.getHeight(), RGB);
      fromBitmap(src, dst);
      return dst;
    }
    
    public static void fromBitmap(Bitmap src, Picture dst) {
      int[] dstData = dst.getPlaneData(0);
      int[] packed = new int[src.getWidth() * src.getHeight()];
    
      src.getPixels(packed, 0, src.getWidth(), 0, 0, src.getWidth(), src.getHeight());
    
      for (int i = 0, srcOff = 0, dstOff = 0; i < src.getHeight(); i++) {
        for (int j = 0; j < src.getWidth(); j++, srcOff++, dstOff += 3) {
          int rgb = packed[srcOff];
          dstData[dstOff]     = (rgb >> 16) & 0xff;
          dstData[dstOff + 1] = (rgb >> 8) & 0xff;
          dstData[dstOff + 2] = rgb & 0xff;
        }
      }
    }
    
    public static Bitmap toBitmap(Picture src) {
      Bitmap dst = Bitmap.create(pic.getWidth(), pic.getHeight(), ARGB_8888);
      toBitmap(src, dst);
      return dst;
    }
    
    public static void toBitmap(Picture src, Bitmap dst) {
      int[] srcData = src.getPlaneData(0);
      int[] packed = new int[src.getWidth() * src.getHeight()];
    
      for (int i = 0, dstOff = 0, srcOff = 0; i < src.getHeight(); i++) {
        for (int j = 0; j < src.getWidth(); j++, dstOff++, srcOff += 3) {
          packed[dstOff] = (srcData[srcOff] << 16) | (srcData[srcOff + 1] << 8) | srcData[srcOff + 2];
        }
      }
      dst.setPixels(packed, 0, src.getWidth(), 0, 0, src.getWidth(), src.getHeight());
    }
    

    You can as well wait for JCodec team to implement full Android support, they are working on it according to this: http://jcodec.org/news/no_deps.html

    0 讨论(0)
  • 2020-12-16 08:03

    you can use following code for screen capturing in Android.

    Please view this url..... http://android-coding.blogspot.in/2011/05/create-custom-dialog-with-dynamic.html

    0 讨论(0)
提交回复
热议问题