如何从本地(cpp)从url加载图像并在android中加载它

Martin j 09/05/2017. 0 answers, 34 views
android android android-ndk android-ndk jni

我正在寻找一种基于在本地cpp端加载图像并在java类中调用该函数以在我的android应用中显示该图像的研究。

  • 目前我只通过传递来自cpp端的字符串(url)来添加图像。
  • 加载图像部分是在java类本身完成的

    private class DownloadImageFromInternet extends AsyncTask {
    ImageView imageView;
    
    public DownloadImageFromInternet(ImageView imageView) {
        this.imageView = imageView;
        Toast.makeText(getApplicationContext(), "Please wait...", Toast.LENGTH_SHORT).show();
    }
    
    protected Bitmap doInBackground(String... urls) {
        String imageURL = urls[0];
        Bitmap bimage = null;
        try {
            InputStream in = new java.net.URL(imageURL).openStream();
            bimage = BitmapFactory.decodeStream(in);
    
        } catch (Exception e) {
            Log.e("Error Message", e.getMessage());
            e.printStackTrace();
        }
        return bimage;
    }
    
    protected void onPostExecute(Bitmap result) {
        imageView.setImageBitmap(result);
    }
    
    
    } 

这是我在Android端加载图片的示例代码

No Answers Yet

Related questions

Hot questions

Language

Popular Tags