网址位图PanoramaGL观众 [英] URL to Bitmap for PanoramaGL viewer

查看:521
本文介绍了网址位图PanoramaGL观众的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作应该连接到一个URL的应用程序,检索图像作为位图,然后显示它的基础上PanoramaGL库观众。

I'm working on an app that should connect to a URL, retrieve the image as Bitmap and then show it in a viewer based on PanoramaGL library.

问题是,即使日志说,图像被逮住,显示屏仍然是黑屏。

The problem is that even if Log says that the image is catched, the display remains blank.

下面是code我使用检索位图也是继非常详细的解答,我发现那里的如何在Android中通过URL加载的ImageView?。 - 其实我想读取图像的情况下直接高速缓存或等

Here is the code I'm using to retrieve the bitmap also following the very detailed answer I found there How to load an ImageView by URL in Android?. -- in fact i'd like to read the image directly without cache or so on.

正如你将看到的$大部分地区C $ CS由在线教程被当作我刚开始的深化发展。

As you will see most parts of codes are taken from online tutorials as I'm just starting developping.

PanoramaActivity.java(以测试它可以用作在MainActivity)

PanoramaActivity.java (in order to test it can be used as the MainActivity)

import java.io.InputStream;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.panoramagl.PLImage;
import com.panoramagl.PLSpherical2Panorama;
import com.panoramagl.PLView;

public class PanoramaActivity extends PLView {

Private static final String TAG = "+++++++++++++++";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.panorama_activity_main);
    new DownloadImageTask(this).execute("http://www.pianetacellulare.it/UserFiles/image/Android/Jelly%20Bean/photo_sphere_esempio.jpg");
}

private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {

    PanoramaActivity pan;

    public DownloadImageTask(PanoramaActivity act) {
        this.pan = act;
    }

    protected Bitmap doInBackground(String... urls) {
        String urldisplay = urls[0];
        Bitmap mIcon11 = null;
        try {
            InputStream in = new java.net.URL(urldisplay).openStream();
            mIcon11 = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return mIcon11;
    }

    protected void onPostExecute(Bitmap result) {
        Log.d(TAG,"onPostExecute");
        PLSpherical2Panorama panorama = new PLSpherical2Panorama();
        panorama.setImage(new PLImage(result));
        pan.setPanorama(panorama);
    }
}   
}

我创建的构造函数传递PanoramaActivity因为我想,应用程序流,直到onPostExecute方法,并有我需要找到一种方式来显示图像。
如果我错了或者有什么更好的方法,请让我知道。

I've created the constructor passing PanoramaActivity as I suppose that the app flow until onPostExecute method and there I need to find a way to display the image. If I'm wrong or there are any better ways please let me know.

我也发布panorama_activity_main.xml布局测试:

I'm posting also panorama_activity_main.xml layout for tests:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".PanoramaActivity" >
</RelativeLayout>

任何提示AP preciated,在此先感谢:)

Any hints appreciated, thanks in advance :)

更新。我试着用ImageView的,而不是PLView相同AsyncTask的类,图像就出来了,所以图像的下载做得正确。有一些是在使用PanoramaGL的这是不正确

UPDATE. I tried the same AsyncTask class using ImageView instead of PLView, and the image came out, so the download of the image is correctly done.. There is something in the use of PanoramaGL which is incorrect

推荐答案

删除

setContentView(R.layout.panorama_activity_main);

它覆盖的图像。 - >即使我不为什么已了解发生这种情况。

it is overwriting image. --> even if I do not undestand why this happens

和高于一切..请确保您链接到图片如下要求:

And above all.. be sure that the image you are linking to follows requirement:

PanoramaGL只支持与两个例如功率大小的图像2048×1024,1024×1024,1024×512,512×512,512x256,256x256的,256x128。

PanoramaGL only supports images with sizes at power of two e.g. 2048x1024, 1024x1024, 1024x512, 512x512, 512x256, 256x256, 256x128.

这篇关于网址位图PanoramaGL观众的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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