Bitmap.createBitmap的6個重載方法

  1. public static Bitmap createBitmap (Bitmap src)
    從原位圖src複製出一個新的位圖,和原始位圖相同

  2. public static Bitmap createBitmap (int[] colors, int width,     int height, Bitmap.Config     config) 
    這個函數根據顏色數組來創建位圖,注意:顏色數組的長度>=width*height

    此函數創建位圖的過程可以簡單概括爲爲:更加width和height創建空位圖,然後用指定的顏色數組colors來從左到右從上至下一次填充顏色。config是一個枚舉,可以用它來指定位圖“質量”。

  3. public static Bitmap createBitmap (int[] colors, int offset,     int stride, int width, int height, Bitmap.Config     config)
    此方法與2類似,但我還不明白offset和stride的作用。

  4. 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
  5. public static Bitmap createBitmap (int width, int height, Bitmap.Config     config)
    根據參數創建新位圖

  6. public static Bitmap createBitmap (Bitmap source, int x,     int y, int width, int height) 

    簡單的剪切圖像的方法,可以參考上面的4.

轉自:http://www.cnblogs.com/igrl/archive/2010/07/30/Bitmap_createBitmap.html

 

發佈了19 篇原創文章 · 獲贊 3 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章