2017年3月5日 星期日

Image Effects

 Image Effects



 Image Effects:android 允許在圖片上做效果。例如:亮度、暗度、灰階…等。


 android 提供Bitmap類別處理圖片。可以在android.graphics.bitmap.找到。要建立一個點陣圖在imageView裡。


private Bitmap bmp;
private ImageView img;
img = (ImageView)findViewById(R.id.imageView1);
BitmapDrawableabmp=(BitmapDrawable)img.getDrawable();

 getDrawable:取得圖片。

 取得點陣圖需要getBitmap()方法。

  bmp = abmp.getBitmap();


     圖像不過是一個二維矩陣。 相同的方式將處理位圖。 圖像是由像素組成的。 所以,你會從中得到位圖像素,並應用處理它。

    for(int i=0; i<bmp.getWidth(); i++){
   for(int j=0; j<bmp.getHeight(); j++){
      int p = bmp.getPixel(i, j);
   }
}


    copy(Bitmap.Config config, boolean isMutable):複製此點陣圖的像素到新點陣圖。

    createBitmap(DisplayMetrics display, int width, int height, Bitmap.Config config):建立新建的點陣圖,自己設定長、寬。

   createBitmap(int width, int height, Bitmap.Config config)建立新建的點陣圖,自己設定長、寬。

   createBitmap(Bitmap src):建立跟 src一樣的點陣圖

   extractAlpha()取得原來點陣圖的Alpha值

   getConfig()取得點陣圖格式。例如:ARGB_8888。

   getDensity()取得影像或是圖像畫面的密度

  getRowBytes()每一列點陣圖所佔用的Byte數(點陣圖的資料)。
  1 pixel=占用4Byte,1 row(列)=4Byte * Width(點陣圖寬度)
  setPixel(int x, int y, int color)針對點陣圖的一點設定顏色。

  setDensity(int density)設定影像或是圖像畫面的密度,會參考手機畫面的密度

參考文獻  





沒有留言:

張貼留言