亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android圖像處理之霓虹濾鏡效果

 更新時間:2021年05月09日 09:13:20   作者:HQUZkP  
這篇文章主要介紹了Android圖像處理之霓虹濾鏡效果的相關資料,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

霓虹是用來描繪圖像的輪廓,勾畫出顏色變化的邊緣,加強其過度效果,使圖像產生輪廓發(fā)光的效果。

主要步驟:

1、根據(jù)當前像素與其右方和下方像素的梯度運算;
2、然后將結果值作為當前像素值,即將原圖當前下像素的RGB分量與其右方和下方像素做梯度 運算(差的平方和平方根);
3、然后將梯度值作為處理后的像素的RGB三個分量;

用代碼實現(xiàn)如下:

//霓虹 
public static Bitmap Neon(Bitmap bitmap){ 
  int w = bitmap.getWidth(); 
  int h = bitmap.getHeight(); 
 
  Bitmap resultBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); 
  int color = 0; 
  int r,g,b,r1,g1,b1,r2,g2,b2; 
 
  int[] oldPx = new int[w * h]; 
  int[] newPx = new int[w * h]; 
 
  bitmap.getPixels(oldPx, 0, w, 0, 0, w, h); 
  for(int y = 0; y < h - 1; y++){ 
    for(int x = 0; x < w - 1; x++){ 
      color = oldPx[x+y*w]; 
 
      r = (color >> 16) & 0xFF; 
      g = (color >> 8) & 0xFF; 
      b = (color >> 0) & 0xFF; 
 
      int newcolor = oldPx[x+1+y*w]; 
 
      r1 = (newcolor >> 16) & 0xFF; 
      g1 = (newcolor >> 8) & 0xFF; 
      b1 = (newcolor >> 0) & 0xFF; 
 
      int newcolor2 = oldPx[x+(y+1)*w]; 
 
      r2 = (newcolor2 >> 16) & 0xFF; 
      g2 = (newcolor2 >> 8) & 0xFF; 
      b2 = (newcolor2 >> 0) & 0xFF; 
 
      int tr = (int) (2*Math.sqrt(((r-r1)*(r-r1)+(r-r2)*(r-r2)))); 
      int tg = (int) (2*Math.sqrt(((g-g1)*(g-g1)+(g-g2)*(g-g2)))); 
      int tb = (int) (2*Math.sqrt(((b-b1)*(b-b1)+(b-b2)*(b-b2)))); 
 
      newPx[x+y*w] = (255 << 24)|(tr << 16)|(tg << 8)|(tb); 
    } 
  } 
  resultBitmap.setPixels(newPx, 0, w, 0, 0, w, h); 
  return resultBitmap; 
} 

對應的效果圖如下:

原圖如下:

挺具有魔幻色彩的。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論