如何在ARCore中显示PNG图像? [英] How to display PNG image in ARCore?

查看:121
本文介绍了如何在ARCore中显示PNG图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Arcore中显示2d png图像.我不想使用obj,.smf,imgdb文件和3D图像.我已经提到了很多链接,但是没有一个链接显示如何使用Arcore仅显示2d png图像.

I want to display 2d png image in Arcore. I don’t want to use obj, .smf ,imgdb file, and 3D image. I have already referred many links but none of them showing how to display only 2d png image using Arcore.

https://github.com/google-ar/arcore-android-sdk

https://developers.google.com/ar/develop/java/quickstart

推荐答案

如果使用

If you use ViewRenderable of Sceneform, then you can create a wall in AR space from 2D png image just like standard android widgets.

这是ViewRenderable的布局xml的示例.如您所知,这只是Android应用程序的布局xml;)

This is an example of layout xml for ViewRenderable. As you know, it's just a layout xml for Android apps ;)

<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/imageCard"
    android:layout_width="123dp"
    android:layout_height="197dp"
    android:src="@drawable/Your_Image_Resource" />

您可以在Java代码中获取ImageView实例,如下所示,以动态设置源图像.

And you can get ImageView instance in your Java code like below to set a source image dynamically.

ViewRenderable.builder()
    .setView(fragment.getContext(), R.layout.imgboard)
    .build()
    .thenAccept(renderable -> {
        ImageView imgView = (ImageView)renderrable.getView();
    });

这是我使用ViewRenderable拍摄的示例,最右边的对象是从png图像创建的.

This is my sample shot with using ViewRenderable, the object on the far right was created from a png image.

这篇关于如何在ARCore中显示PNG图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆