3

ペイント機能を実装しました。ユーザーの操作を記録してビデオファイルとして保存したい。IPADのアプリケーション「SHOWME」のように。どうやってやるの?

4

1 に答える 1

-2

次のコードを使用して、独自のアプリのスクリーンショットを撮ることができます (アプリに応じて少し変更します)。

public class AndroidWebImage extends Activity {

ImageView bmImage; 
LinearLayout view;
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);

      view = (LinearLayout)findViewById(R.id.screen);
      bmImage = (ImageView)findViewById(R.id.image);

      view.setDrawingCacheEnabled(true);
      // this is the important code :)  
      // Without it the view will have a dimension of 0,0 and the bitmap will be null          

      view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 
            MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));

      view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); 

      view.buildDrawingCache(true);
      Bitmap b = Bitmap.createBitmap(view.getDrawingCache());
      view.setDrawingCacheEnabled(false); // clear drawing cache

      bmImage.setImageBitmap(b);   

};


}

次のxmlを使用しました。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
   android:id="@+id/screen"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  >
<TextView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="@string/hello"
  />
<ImageView
  android:id="@+id/image"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
/>
</LinearLayout>

タイマーを使用して一定の時間間隔でスクリーンショットを撮り、この一連の画像を次のようなビデオ ファイルに変換します: create-a-video-file-from-images-using-ffmpeg

于 2012-06-01T05:25:28.183 に答える