How do you get the RGB values from a Bitmap on an Android device?

前端 未结 5 2043
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 20:22

I want to get RGB values of bitmap in android but I cant do this so far. My aim is to obtain RGB values for each pixel of bitmap. Is there any specific function for android

5条回答
  •  没有蜡笔的小新
    2020-11-29 21:07

    Bitmap.getPixel(x, y) returns an int with the colour values and alpha value embedded into it.

    int colour = bitmap.getPixel(x, y);
    
    int red = Color.red(colour);
    int blue = Color.blue(colour);
    int green = Color.green(colour);
    int alpha = Color.alpha(colour);
    

提交回复
热议问题