文章目錄
Bitmap.createBitmap函數有6個重載方法
位元影像剪下參考重載方法4和6,重載方法6比較簡單
- public static Bitmap createBitmap (Bitmap src)
從原位元影像src複製出一個新的位元影像,和原始位元影像相同
- public static Bitmap createBitmap (int[] colors, int width,
int height, Bitmap.Config
config)
這個函數根據顏色數組來建立位元影像,注意:顏色數組的長度>=width*height
此函數建立位元影像的過程可以簡單概括為為:更加width和height建立空位元影像,然後用指定的顏色數組colors來從左至右從上至下一次填充顏色。config是一個枚舉,可以用它來指定位元影像“品質”。
- public static Bitmap createBitmap (int[] colors, int offset,
int stride, int width, int height, Bitmap.Config
config)
此方法與2類似,但我還不明白offset和stride的作用。
- public static Bitmap createBitmap (Bitmap source, int x,
int y, int width, int height, Matrix m, boolean
filter)
從原始位元影像剪下映像,這是一種進階的方式。可以用Matrix(矩陣)來實現旋轉等進階方式
參數說明:
Bitmap source:要從中的原始位元影像
int x:起始x座標
int y:起始y座標
int width:要截的圖的寬度
int height:要截的圖的寬度
Bitmap.Config config:一個枚舉類型的配置,可以定義截到的新位元影像的品質
傳回值:返回一個剪下好的Bitmap
- public static Bitmap createBitmap (int width, int height, Bitmap.Config
config)
根據參數建立新位元影像
- public static Bitmap createBitmap (Bitmap source, int x,
int y, int width, int height) 簡單的剪下映像的方法,可以參考上面的4.
一些不明白的地方
- Bitmap.Config 如何控制Bitmap建立
- 在 Bitmap.createBitmap的重載版本4中參數offset、stride和filter的作用是什麼