bitmap的createScaledBitmap();(转)

通过Bitmap.createScaledBitmap (Bitmap src, int dstWidth, int dstHeight, boolean filter);

可以根据原来的位图创建一个新的位图。API中是这样解释的:

Creates a new bitmap, scaled from an existing bitmap.

Parameter
src The source bitmap.
dstWidth The new bitmap's desired width.
dstHeight The new bitmap's desired height.
filter true if the source should be filtered.

关于参数filter,另一位的描述是这样的----------:

奶勒呀,filter是什么东东,解释的个几呀~~过滤?过滤什么呀?但是我在自定义的控件中使用到了自定义的属性传进来的Drawable之后把图片createScaledBitmap之后,再用canvas.drawBitmap()画到我们的Canvas上,会出现一个非常恼的问题,图片的质量居然指数级别的下降,以前的透明渐变效果现在表现的非常的不好,我看了下我的filter参数,我设的是false,以前根本就不知道这个参数是干什么的,于是,我就径直把它设成了flase,这一来呢,哎,图片失真了,所以说,变成true吧,靠~~效果杠杠地~

借鉴之!

原文地址:https://www.cnblogs.com/tiejiangweigaibianercunzai/p/3798134.html