如何从Android应用程序显示360全景

时间:2013-12-16 13:24:22

标签: android panoramas

我想从我的Android应用程序中显示一个全景图,这个全景图是在线的,我有它的网址我将它加载到webview上,但它无法正常工作。它只是它的一部分,它不会转动或颠倒。我不知道从哪里开始,你能指出我正确的方向吗?提前谢谢你

3 个答案:

答案 0 :(得分:4)

经过大量研究后我发现这个库仍然很新,但肯定可以帮助你从一些东西开始。我发布它只是为了节省其他搜索者的时间!干杯 PanoramaGl

答案 1 :(得分:0)

  1. 在gradle(app-level)中添加依赖项

    compile 'com.google.vr:sdk-panowidget:1.80.0'

  2. 在xml中添加VrPanoramaView并通过android中的findViewById()方法获取引用

  3. 以下是从资产加载图片的代码。

  4. VrPanoramaView将输入视为Bitmap,因此我们需要先输入 将其转换为正确的格式。这里,loadPhotoSphere功能 在onCreate()

    中调用
    private void loadPhotoSphere() {
      VrPanoramaView.Options options = new VrPanoramaView.Options();
      InputStream inputStream = null;
    
      try {
          inputStream = assetManager.open("image.jpg");
          options.inputType = VrPanoramaView.Options.TYPE_MONO;
          mVRPanoramaView.loadImageFromBitmap(BitmapFactory.decodeStream(inputStream), options);
          inputStream.close();
      } catch (Exception e) {
          e.printStackTrace();
      }
    }
    

    了解适用于Android的Google VR SDK here

答案 2 :(得分:0)

我在科特林也有类似情况,但是我需要从URL获取图像。我用毕加索解决了。我将其留在此处以备将来参考:

    val options = VrPanoramaView.Options()
    val url = "https://urltoyourimage.com/image.jpg"

    Picasso.get().load(url)
        .into(object : Target {
            override fun onBitmapLoaded(bitmap: Bitmap?, from: Picasso.LoadedFrom?) {
                options.inputType = VrPanoramaView.Options.TYPE_MONO
                vrPanoramaView.loadImageFromBitmap(bitmap, options)
            }

            override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) {
                print(e?.localizedMessage)
            }

            override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
                print(placeHolderDrawable)
            }
    })
相关问题