Android中Bitmap.createBitmap重載方總結 和 Android實現位元影像剪下

來源:互聯網
上載者:User
文章目錄
  •  一些不明白的地方
  Bitmap.createBitmap函數有6個重載方法

  位元影像剪下參考重載方法4和6,重載方法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.

     

 一些不明白的地方
  1. Bitmap.Config 如何控制Bitmap建立

  2. 在 Bitmap.createBitmap的重載版本4中參數offset、stride和filter的作用是什麼
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.