【问题标题】:How can I extract a portion of a camera?如何提取相机的一部分?
【发布时间】:2014-11-07 02:22:38
【问题描述】:

我在我的“插入照片框架”应用程序中像本教程一样在 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>

如何从相机中提取内部部分的帧图像?

【问题讨论】:

    标签: android camera imageview android-framelayout


    【解决方案1】:
            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
                    }
                }
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-18
      • 2019-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-19
      • 1970-01-01
      • 2010-11-24
      相关资源
      最近更新 更多