What does the filter parameter to createScaledBitmap do?
The declaration of android.graphics.Bitmap.createScaledBitmap
is
public static Bitmap createScaledBitmap
(Bitmap src, int dstWidth, int dstHeight, boolean filter)
However, the documentation doesn't explain any of the parameters. All of them are pretty obvious except for boolean filter
. Does anyone know what it does?
A quick dig through the SKIA source-code indicates that (at least by default) the FILTER flag causes it to do a straightforward bilinear interpolation. Check Wikipedia or your favorite graphics reference to see what the expected consequences are. Traditionally, you want to do bilinear or bicubic interpolation when upsizing images, and area averaging when downsizing images. I get the impression (though I'm glad to be corrected) that Android/Skia does simple subsampling when downsizing without filtering, so you are likely to get better results from filtering even when downsizing. (There's an alternate method for getting high quality downsizing with interpolation, involving doing a series of 50% scale reductions. See http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html for details.)
过滤器将设置FILTER_BITMAP_FLAG进行绘制,从而在根据您提供的值转换位图时对其进行采样。
链接地址: http://www.djcxy.com/p/16622.html