I'm working one a image processing app for Android.
I've got about 27 filters and effect that the user will be able to use.
But i would like to optimize them.
I've made it so the program will resize big images down to 1.2Mp, and I'm running all processing in threads.
But still, a simple invert takes about 5-10 seconds on a real Device (SonyEricsson Xperia Arc, 4.0.3 Stock)
It must be something i can do to optimize speed.
Here is the code i use for inverting the image:
public static Bitmap doInvert(Bitmap src) {
// Skapa en ny bitmap med samma egenskaper som käll-bilden
Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
// Färg infor
int A, R, G, B;
int pixelColor;
// Bildstorlek
int height = src.getHeight();
int width = src.getWidth();
// Skanna igenom alla pixlarna
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
// Hämta en pixel
pixelColor = src.getPixel(x, y);
// Spara alpha-kanal
A = Color.alpha(pixelColor);
// invertera världen för varje R/G/B kanal
R = 255 - Color.red(pixelColor);
G = 255 - Color.green(pixelColor);
B = 255 - Color.blue(pixelColor);
// Sätt ny-inverterade pixlarna till slutgiltiga bitmapen
bmOut.setPixel(x, y, Color.argb(A, R, G, B)/>);
}
}
// returera slutgiltiga bitmapen
return bmOut;
}
Hope someone would be kind to help me optimize my algorithms and code
Thanks in advance

New Topic/Question
Reply



MultiQuote


|