2014-11-07 61 views
0

我在我的「插入框架照片」應用程序中使用Android中的相機應用程序 http://developer.android.com/guide/topics/media/camera.html 我在FrameLayout中有一個ImageView插入一個圖像框架,內部部分是透明的。如何提取相機的一部分?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

     <FrameLayout 
      android:id="@+id/camera_container" 
      android:layout_width="fill_parent" 
      android:layout_height="match_parent" 
      android:gravity="top" 
      android:orientation="vertical" > 
     </FrameLayout> 

     <ImageView 
      android:id="@+id/grid" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:src="@drawable/demo" /> 
    </RelativeLayout> 

</LinearLayout> 

如何從相機中提取幀內圖像?

回答

0
 private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100; 
     private static final int CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE = 200; 

     @Override 
     protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
      if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { 
       if (resultCode == RESULT_OK) { 
        // Image captured and saved to fileUri specified in the Intent 
        Toast.makeText(this, "Image saved to:\n" + 
          data.getData(), Toast.LENGTH_LONG).show(); 
       } else if (resultCode == RESULT_CANCELED) { 
        // User cancelled the image capture 
       } else { 
        // Image capture failed, advise user 
       } 
      } 

      if (requestCode == CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) { 
       if (resultCode == RESULT_OK) { 
        // Video captured and saved to fileUri specified in the Intent 
        Toast.makeText(this, "Video saved to:\n" + 
          data.getData(), Toast.LENGTH_LONG).show(); 
       } else if (resultCode == RESULT_CANCELED) { 
        // User cancelled the video capture 
       } else { 
        // Video capture failed, advise user 
       } 
      } 
     }