读图片
来源:互联网 发布:入骨相思知不知好看吗 编辑:程序博客网 时间:2024/04/25 20:18
//读图片URL
URLuri=new URL("http://10.1.5.42:8080/ru.png");
HttpURLConnectionconnection = (HttpURLConnection) uri.openConnection();
connection.setConnectTimeout(5000);
connection.setRequestMethod("GET");
connection.setReadTimeout(5000);
connection.connect();
int code = connection.getResponseCode();
if(code==200){
InputStream inputStream = connection.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
}
//读图片HttpClient
Path:图片的网址;
HttpClientclient=new DefaultHttpClient();
HttpPost httpPost=new HttpPost(path);
try {
HttpResponse httpResponse =client.execute(httpPost);
//得到实体数据
HttpEntity entity =httpResponse.getEntity();
//从实体里获得流
InputStream inputStream =entity.getContent();
//把流转成bitmap
final Bitmap bitmap =BitmapFactory.decodeStream(inputStream);
runOnUiThread(new Runnable() {
@Override
public void run() {
imageView.setImageBitmap(bitmap);
}
//读图片HttpClient导包
<com.loopj.android.image.SmartImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="100dp"/>
SmartImageView imageView= (SmartImageView)convertView.findViewById(R.id.imageView);
imageView.setImageUrl(list.get(position).pic);
//读图片导包Utils
BitmapUtils bitmap=new BitmapUtils(context);
bitmap.display(imageview, str[position]);
- 读图片
- ashx读图片
- ashx读图片
- opencv读图片
- 批量读图片到数据库
- 读图片的绝对地址
- java 从Oracle读图片
- c#—MemoryStream读图片存入ImageList
- 读图片输出流在前台展现
- 写批处理命令bat读图片路径
- python模块imghdr读图片后缀名
- 从数据库读图片并在页面中显示
- Android中读图片Exif信息的方法
- 从数据读图片保存到imageList里面
- openCV3.2.0-imread读图片为空值
- web项目通过IO流读图片遇到错
- 从库中读图片显示到页面上的主要源码
- 从库中读图片显示到页面上的主要源码
- spring TaskScheduler 来实现定时任务
- 关系表与非关系表的区别
- Highcharts基本用法
- eclipse 中使用 RecyclerView
- oracle 游标使用根据工龄更新年假
- 读图片
- MongoDB执行计划学习整理
- Nginx安装遇到的问题
- 关于 ng-repeat
- C++程序设计语言练习6.3 multimap标准库的使用
- UITextView内容垂直居中
- 修改android-自定义控件-悬浮控件-仿360手机助手应用详情页
- 9 patch png 的上下左右
- Android自定义弹窗——右上角悬浮关闭