问题
I am new at android and I have a project to take a picture save it and compute its signature. I've taken the picture and saved it already.
Its signature consists in computing the mean of all pixels values in RGB. The problem is that I dont know how to work with pixels and colors.
Can you help me with some explanations and/or tutorials and/or code.
Thank you
回答1:
Here is code to get pixel from bitmap.
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int pixel;
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
// get pixel color
pixel = bitmap.getPixel(x, y);
int A = Color.alpha(pixel);
int R = Color.red(pixel);
int G = Color.green(pixel);
int B = Color.blue(pixel);
}
}
来源:https://stackoverflow.com/questions/16237195/working-with-pixels-in-android