我正在開發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;
}}
請告訴我們你做了什麼..不要期望SO會員爲你的想法做編碼.. – Lal
@Lal我編輯了這個問題 – tiagopotencia