您的位置:首页 > 其它

【bug】:Bitmap.createScaledBitmap不能满屏

2015-04-27 14:35 573 查看
缩放一个 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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: