2014-05-23 65 views
0

我正在開發Android圖像編輯器應用程序。我試圖使用純Java創建圖像過濾器,但速度太慢!我聽說過有關OPENGL ES 2(Android的EffectFactory類使用它)和RenderScript的一些信息,但我確實沒有找到說明「處理圖像(例如應用圖像濾鏡)的文檔或教程,您需要這樣做!」。創建圖像過濾器時圖像處理過慢

我使用這個代碼:

public static Bitmap doColorFilter(Bitmap src, double red, double green, double blue) { 
    // image size 
    int width = src.getWidth(); 
    int height = src.getHeight(); 
    // create output bitmap 
    Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); 
    // color information 
    int A, R, G, B; 
    int pixel; 

    // scan through all pixels 
    for(int x = 0; x < width; ++x) { 
     for(int y = 0; y < height; ++y) { 
      // get pixel color 
      pixel = src.getPixel(x, y); 
      // apply filtering on each channel R, G, B 
      A = Color.alpha(pixel); 
      R = (int)(Color.red(pixel) * red); 
      G = (int)(Color.green(pixel) * green); 
      B = (int)(Color.blue(pixel) * blue); 
      // set new color pixel to output bitmap 
      bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 
     } 
    } 

    // return final image 
    return bmOut; 
}} 
+2

請告訴我們你做了什麼..不要期望SO會員爲你的想法做編碼.. – Lal

+0

@Lal我編輯了這個問題 – tiagopotencia

回答

0

我希望android-jhlabs將是有益的。它有許多可以使用的圖像過濾算法。
這裏是過濾器的使用細節:FilterUsage

這裏是進行圖像處理的另一個有用的庫:的OpenCV android-lib-magick

渣口 - JavaCV已經可以使用也有很多圖像處理類。

這裏是圖像處理的教程,我自己建議你遵循:
Image Processing Tutorial

THANX!

+0

我在我的應用程序中使用了最後一個教程的代碼。它非常好但非常慢! hehehe – tiagopotencia

+1

播放位圖是一個緩慢的操作。還使用AsyncTask進行後臺處理。 – captaindroid

0

你正在尋找的是非常廣泛的概念,它不是像我 將張貼我的答案,你得到所有你需要的。

我發現了斯坦福大學代表的一些很好的例子。關於圖像處理的概念。 http://www.stanford.edu/class/ee368/Android/

我希望這會幫助您開始,但正如我所說的要走很長的路!