【bug】:Bitmap.createScaledBitmap不能满屏

来源:互联网 发布:三维数据图表ae模板 编辑:程序博客网 时间:2024/05/22 04:26

缩放一个 Bitmap

可以用 Bitmap.createScaledBitmap() 方 法根据给定的 Bitmap 创建 一个新的,缩放后的 Bitmap (该方法可以将一个Bitmap生成指定大小的BItmap,该方法可以放大图片也可以缩小图片。

Bitmap mBitmap = Bitmap.createScaledBitmap(bmp, mScreenWidth, mScreenHeight, true); 
其中 mScreenWidth 和 mScreenHeight 是屏幕的宽度和高度,这里就将 bmp 拉伸到整个屏幕。

public static Bitmap createScaledBitmap (Bitmap src, int dstWidth, int dstHeight, boolean filter)

Creates a new bitmap, scaled from an existing bitmap.

Parameters
srcThe source bitmap.dstWidthThe new bitmap's desired width.dstHeightThe new bitmap's desired height.filtertrue if the source should be filtered.(filter决定是否平滑,如果是缩小图片,filter无影响
What does the filter parameter to createScaledBitmap do? (来自stackoverflow.com)

解决;imageView.setScaleType(ImageView.ScaleType.FIT_XY);
     imageView.setImageBitmap(mBitmap);
0 0