画像処理機能を実装しようとしています。ここにあります:
typedef void (*AgFilter)(int*, int*, int*, float*);
static void filter(AndroidBitmapInfo* info, void* pixels, AgFilter func, void* params){
for(y = 0; y < height; y++){
for(x = 0; x < width; x++){
//initizalie r, g, b
func(&r, &g, &b, params); //here is the problem
}
}
}
私はこの関数を次のように渡していますfunc
:
static inline void brightness(int *r, int *g, int *b, float* param){
float add = param[0];
*r += add;
*g += add;
*b += add;
}
動作が極端に遅いという問題。なるほど、それは理解できます。しかし、参照によって関数を渡す代わりに、filter
(呼び出しの instread func
) 内に関数を直接記述すると、はるかに高速に動作します。問題はどこだ?
PSはそうではないことに注意してくださいc++
編集
これは高速に動作します:
static void filter(AndroidBitmapInfo* info, void* pixels, int add){
for(y = 0; y < height; y++){
for(x = 0; x < width; x++){
//initizalie r, g, b
r += add;
g += add;
b += add;
}
}
}