通過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吧,靠~~效果杠杠地~
借鑒之!
