在imageview中从android studio访问sql server“image”数据类型中的图像存储 [英] Accessing image store in sql server “image” data type from android studio in imageview

查看:267
本文介绍了在imageview中从android studio访问sql server“image”数据类型中的图像存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android studio的新手,我想在android studio中显示来自SQL serverimage数据类型的图像。我的网站已经在生产中运行,并且在asp.net中工作正常,因此转换其他数据类型的图像是不可行的,因为它需要大量测试。请帮助。



我尝试过:



我已经在网上查了一下,但没有找到任何帖子。

I am very new to android studio , i want to show the images from SQL server "image" data type in android studio. My web site is already running in production and which is working fine in asp.net hence it is not feasible to convert the images in other data type as it will require large testing . Pls help.

What I have tried:

I have checked on net , but not found any post on this.

推荐答案

图像以字节数组的形式发送。你可以使用从sql server到你的android应用程序的RestFUll api来访问它们。

图像将在json中检索,然后从bytes数组转换为图像。

Images are sent in the form of bytes array. you can access them by using a RestFUll api from sql server to your android application.
image will be retrieved in json and then converted to image from bytes array.
JSONArray jsonArray = new JSONArray(jsonString);
for (int i = 0; i < jsonArray.length(); i++) {
    JSONObject jsonObject = (JSONObject) jsonArray.get(i);


    byte[] byteArray =  Base64.decode(jsonObject.getString("image"), Base64.DEFAULT) ;
    Bitmap bmp1 = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);

   
}



bmp1是图片,您可以根据需要使用


bmp1 is the image, you can use it according to your needs


这篇关于在imageview中从android studio访问sql server“image”数据类型中的图像存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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