Working with pixels in android

久未见 提交于 2019-12-12 02:54:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!