android 图片的压缩
16lz
2021-01-23
private static int calculateInSampleSize( BitmapFactory.Options options, int reqWidth, int reqHeight) { final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) { if (height > reqHeight && reqHeight != 0) { inSampleSize = (int) Math.floor((double) height / (double) reqHeight); } int tmp = 0; if (width > reqWidth && reqWidth != 0) { tmp = (int) Math.floor((double) width / (double) reqWidth); } inSampleSize = Math.max(inSampleSize, tmp); } int roundedSize; if (inSampleSize <= 8) { roundedSize = 1; while (roundedSize < inSampleSize) { roundedSize <<= 1; } } else { roundedSize = (inSampleSize + 7) / 8 * 8; } return roundedSize; }
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer