图片的总大小 = 图片的总像素 * 每一个像素的大小web
BMP 无损格式svg
单色spa
16色code
256色xml
24位:对象
Android中使用的是ARGB 每一个像素占用4个字节图片
缩放方法:内存
使用Bitmapfactory.Optionsget
opts.inJustDecodeBounds = true ;string
//拿到图片的宽高
int width = opts.outWidth;
int height = opts.outHeight;
* //获取屏幕宽高
Display dp = getWindowManager().getDefaultDisplay();
int screenWidth = dp.getWidth();
int screenHeight = dp.getHeight();
* //计算缩放比例
int scaleWidth = width / screenWidth;
int scaleHeight = height / screenHeight;
int scale = 1;
* //肯定使用哪一个缩放比例 使用大的那个
if (scaleWidth >= scaleHeight && scaleWidth > 0) {
scale = scaleWidth;
} else if (scaleWidth < scaleHeight && scaleHeight > 0) {
scale = scaleHeight;
}
* //设置缩放比例
opts.inSampleSize = scale;
opts.inJustDecodeBounds = false;
Bitmap bm = BitmapFactory.decodeFile("sdcard/Download/hello.png", opts);
iv.setImageBitmap(bm);