Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在ARCore视图上获取带有贴图的位图_Android_Dictionary_Screenshot_Capture_Arcore - Fatal编程技术网

Android 如何在ARCore视图上获取带有贴图的位图

Android 如何在ARCore视图上获取带有贴图的位图,android,dictionary,screenshot,capture,arcore,Android,Dictionary,Screenshot,Capture,Arcore,我正在尝试自己保存应用程序的快照。 它由ARCore和MapFragment组成 我无法从环绕着它的碎片布局中一次拍摄快照。 所以,我得到了一个位图给对方 从DrawLayout(它结合了ARCore)获取位图效果很好。 但是,MapFragment中的位图看起来像带有Google标记的玻璃 这是我的源代码。 我希望有人能告诉我原因 谢谢你的阅读 我认为MapFragment构成了一个子对象。 所以我试着用它制作一个位图 <?xml version="1.0" encoding="utf-

我正在尝试自己保存应用程序的快照。 它由ARCore和MapFragment组成

我无法从环绕着它的碎片布局中一次拍摄快照。 所以,我得到了一个位图给对方

DrawLayout
(它结合了
ARCore
)获取位图效果很好。 但是,MapFragment中的位图看起来像带有Google标记的玻璃

这是我的源代码。 我希望有人能告诉我原因

谢谢你的阅读

我认为
MapFragment
构成了一个子对象。 所以我试着用它制作一个位图

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".MainActivity"
    tools:showIn="@layout/app_bar_main"
    android:id="@+id/arFrameLayout">

    <!-- AR Scene -->
    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="visible">

        <fragment
            android:id="@+id/ux_fragment"
            android:name="com.lx.agnss.WritingArFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <FrameLayout
            android:layout_width="300sp"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:background="#FFFFFF"
            >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="80dp"
                    android:background="#2b3251"
                    android:fontFamily="monospace"
                    android:gravity="left|bottom"
                    android:paddingLeft="25dp"
                    android:paddingBottom="15dp"
                    android:text="@string/info_view_title"
                    android:textColor="#ffffff"
                    android:textSize="20sp"
                    android:paddingRight="10dp"
                    />

                <TextView
                    android:id="@+id/locationView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="8dp"
                    android:layout_marginBottom="8dp"
                    android:background="#88ffffff"
                    android:paddingTop="20dp"
                    android:paddingLeft="20dp"
                    android:paddingRight="10dp"
                    android:text="@string/info_item_title_location"
                    android:textAlignment="viewStart"
                    android:textSize="15sp"
                    android:inputType="textMultiLine"
                    app:layout_constraintEnd_toEndOf="parent" />

                <TextView
                    android:id="@+id/anchorInfoView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="8dp"
                    android:layout_marginBottom="8dp"
                    android:background="#88ffffff"
                    android:paddingTop="20dp"
                    android:paddingLeft="20dp"
                    android:paddingRight="10dp"
                    android:text="Take Coord"
                    android:inputType="textMultiLine"
                    app:layout_constraintTop_toTopOf="@id/locationView"
                    />

                <TextView
                    android:id="@+id/moreMessageView02"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="8dp"
                    android:layout_marginBottom="8dp"
                    android:background="#88ffffff"
                    android:paddingTop="20dp"
                    android:paddingLeft="20dp"
                    android:paddingRight="10dp"
                    android:text="moreMessageView02"
                    android:inputType="textMultiLine"
                    app:layout_constraintTop_toTopOf="@id/locationView"
                    />
            </LinearLayout>
        </FrameLayout>
    </android.support.v4.widget.DrawerLayout>

    <!-- Map layout -->
    <FrameLayout
        android:id="@+id/mapLayout"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        >

        <fragment
            android:id="@+id/mapFragment"
            class="com.google.android.gms.maps.MapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="3dp"
            />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/ic_map_gb_box" />

    </FrameLayout>


</FrameLayout>

JAVA

// Make the request to copy.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
    PixelCopy.request(arSceneView, arBitmap, (copyResult) -> {
        if (copyResult == PixelCopy.SUCCESS) {
            try {
                DrawerLayout fContainer = (DrawerLayout) findViewById(id.masterLayout); //
                fContainer.buildDrawingCache();
                Bitmap bitmapARCash = fContainer.getDrawingCache();
                Bitmap resultArMerge = new ImageTool().mergeToPin(arBitmap, bitmapARCash);
                FragmentManager fragmentManager = mapFragment.getChildFragmentManager();
                List<Fragment> listFragment = fragmentManager.getFragments();

                if (listFragment.size() > 0) {
                    View viewMap = listFragment.get(0).getView();
                    viewMap.buildDrawingCache();
                    Bitmap bitmapMapCash = viewMap.getDrawingCache();
                    Bitmap result = new ImageTool().mergeToPin(resultArMerge, bitmapMapCash);

                    fileTool.saveBitmapToDisk(result, filename);
                } else {
                    fileTool.saveBitmapToDisk(resultArMerge, filename);
                }
            } catch (IOException e) {
                displayToastMsg(e.toString());
                return;
            }
            displaySnackbar("저장완료", filename);
        } else {
            displayToastMsg("Failed to copyPixels: " + copyResult);
        }
    });
}
//请求复制。
if(Build.VERSION.SDK\u INT>=Build.VERSION\u code.N){
PixelCopy.request(arSceneView,arBitmap,(copyResult)->{
if(copyResult==PixelCopy.SUCCESS){
试一试{
抽屉布局fContainer=(抽屉布局)findViewById(id.masterLayout)//
fContainer.buildDrawingCache();
位图bitmapARCash=fContainer.getDrawingCache();
位图结果合并=新的ImageTool().mergeToPin(arBitmap,bitmapARCash);
FragmentManager FragmentManager=mapFragment.getChildFragmentManager();
List listFragment=fragmentManager.getFragments();
如果(listFragment.size()>0){
View viewMap=listFragment.get(0.getView();
buildDrawingCache();
位图BitMapCash=viewMap.getDrawingCache();
位图结果=new ImageTool().mergeToPin(resultArMerge,BitMapCash);
saveBitmapToDisk(结果,文件名);
}否则{
saveBitmapToDisk(结果合并,文件名);
}
}捕获(IOE异常){
显示toastmsg(例如toString());
返回;
}
显示快捷键(“저장완료", 文件名);
}否则{
displayToastMsg(“未能复制像素:+copyResult”);
}
});
}

这没有错