对Bitmap的使用
来源:互联网 发布:js 编辑:程序博客网 时间:2024/05/17 08:57
我自己将它分解成几中情况:
1,Bitmap对sdcard中原图的加载
Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getPath()+"/1106212029490.png");imageView.setImageBitmap(bitmap);
2,以一定的采样因子比例来加载图片
BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getPath() + "/1106212029490.png", opts); //原始图片的宽高 int bitmap_w = opts.outWidth; int bitmap_h = opts.outHeight; //获取屏幕信息 WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); DisplayMetrics displayMetrics = new DisplayMetrics(); display.getMetrics(displayMetrics); //获取屏幕宽高 int sw = displayMetrics.widthPixels; int sh = displayMetrics.heightPixels; //计算各宽高比例 int sampleW = bitmap_w / sw; int sampleH = bitmap_h / sh; //计算采样因子 int sampleSize = (sampleH > sampleW) ? sampleH : sampleW; opts.inJustDecodeBounds = false; opts.inSampleSize = sampleSize; Bitmap bitmap_later = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getPath() + "/1106212029490.png", opts); imageView.setImageBitmap(bitmap_later);
0 0
- 对Bitmap的使用
- 对Bitmap的封装
- Android对Bitmap的高效使用总结(Google给的bitmap终极方案)
- 对Bitmap的内存优化
- 对Bitmap的内存优化
- bitmap的使用
- Bitmap的使用
- Android Bitmap的使用
- Bitmap的使用(一)
- Bitmap的使用(二)
- Bitmap的使用(三)
- Bitmap的使用
- Android Bitmap的使用
- 关于bitmap的使用
- Bitmap的基本使用
- Bitmap的使用
- Android-使用Matrix对Bitmap进行处理
- Bitmap,使用Matrix对图像几何变换
- 工程院院士栾恩杰评价为什么航空和航天取得的成绩差别这么大
- 使用异步任务-AsyncTask下载远程图片
- Extjs之自动消失提示框(Ext.example.msg)
- 学Django过程中的Jekyll搭建静态站小插曲
- 从CPU组成中追溯计算机思想--挖掘系列之一
- 对Bitmap的使用
- 优酷路由宝刷潘多拉固件最详细教程+最新版+赚钱插件
- MATLAB Primitive Types
- 骨肉至亲
- wxPython for mac 安装
- 要怎样努力,才能成为很厉害的人?
- 【u035】奶牛的电信
- Flask--项目结构
- 一个不错的按钮检测程序