Android中图片处理
来源:互联网 发布:伍华聪开发框架源码 编辑:程序博客网 时间:2024/05/24 02:50
加载图片
加载大图: 3648 * 2736
总像素的个数: 9980928每一个像素占用的空间: ARGB_4444(2bytes), ARGB_8888(4bytes), RGB_565(2bytes)图片占用的空间 = 总像素的个数 * 像素的单位.9980928 * 2bytes = 19961856bytes = 19.037109375MB
缩放加载.
- 图片的宽和高: 3648 * 2736
屏幕的宽和高: 320 * 480
计算缩放比例
- 宽度缩放比例: 3648 / 320 = 11;
高度缩放比例: 2736 / 480 = 5;
比较宽和高的缩放比例, 哪一个大用哪一个进行缩放.
进行缩放: 331 * 248 = 82088 * 2bytes = 164176bytes = 160KB
3648 / 11 = 331; 2736 / 11 = 248;
核心代码:String picpath = et_picpath.getText().toString().trim();Options opts = new Options();opts.inJustDecodeBounds = true;BitmapFactory.decodeFile(picpath, opts);int picHeight = opts.outHeight;int picWidth = opts.outWidth;WindowManager manager = getWindowManager();int screenHeight = manager.getDefaultDisplay().getHeight();int screenWidth = manager.getDefaultDisplay().getWidth();int heightScale = picHeight / screenHeight;int widthScale = picWidth / screenWidth;int scale = heightScale > widthScale ? heightScale : widthScale;opts.inJustDecodeBounds = false;opts.inSampleSize = scale;Bitmap bitmap = BitmapFactory.decodeFile(picpath, opts);iv_image.setImageBitmap(bitmap);
0 0
- Android中图片处理
- android中处理图片成圆角
- Android应用开发中图片的处理
- android中常见图片处理方法
- android 中图片的压缩处理
- Android中处理大图片时图片压缩
- Android中图片处理相关问题
- Android中图片处理相关问题
- Android中处理大图片时图片压缩
- Android中处理大图片时图片压缩
- android中相关的图片处理
- Android开发中图片的压缩处理
- Android中处理图片的框架
- android图片处理一
- android 图片放大处理
- android 处理图片资源
- Android处理图片
- android图片处理技巧
- unity3d eclipse下调用java代码(自己研究出来的,与网上流传的稍有区别)
- Android中自带的对话框及通知栏
- 刺杀金正恩 综合下载地址 讯雷 BT 百度云 什么格式都有
- 安卓中的样式(类似于CSS)
- 在 linux 下使用 CMake 构建应用程序
- Android中图片处理
- hrbust1558 小背包 (01背包)
- windbg分析dump文件
- android学习记录-文件操作
- Looper、Handler和Thread的关系
- Centos搭建 TFS Nameserver HA
- Creating a class from scratch(从头开始创建一个类)
- Android中两种播放声音的方法
- 使用MAT分析Java内存