2012-06-01 47 views

回答

0

您可以(根據您的應用程序一點點修改)需要使用下面的代碼自己的應用程序的截圖:

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

+1

有沒有辦法將ffmpeg命令移植到沒有root設備的Android? – user1429903

相關問題