Android 从位图中获取像素颜色

Android 从位图中获取像素颜色,android,android-bitmap,Android,Android Bitmap,我想检查位图部分中像素的颜色。我需要确定黑色像素的起始位置。这是我的实现 Bitmap bmp = SavePixels(0, 0, screenWidth, screenHeight, gl); for(int i = 0; i < 100; i++){ for(int x = 0; x < 50; x++){ //Log.i(EJ.TAG, i+","+x); int pixel = bmp.getPixel(i,x); i

我想检查位图部分中像素的颜色。我需要确定黑色像素的起始位置。这是我的实现

Bitmap bmp = SavePixels(0, 0, screenWidth, screenHeight, gl);
for(int i = 0; i < 100; i++){
    for(int x = 0; x < 50; x++){
        //Log.i(EJ.TAG, i+","+x);
        int pixel = bmp.getPixel(i,x);
        if(pixel == Color.BLACK){
            cordinate = i;
            Log.i(EJ.TAG, i+","+x);
            break;
        }
    }
}
Bitmap bmp=SavePixels(0,0,屏幕宽度,屏幕高度,gl);
对于(int i=0;i<100;i++){
对于(int x=0;x<50;x++){
//Log.i(EJ.TAG,i+“,”+x);
int pixel=bmp.getPixel(i,x);
如果(像素==颜色.黑色){
cordinate=i;
Log.i(EJ.TAG,i+“,”+x);
打破
}
}
}

不幸的是,getPixel方法总是返回0,这应该会找到包含黑色像素的第一列(从左开始):

    Bitmap bmp = SavePixels(0, 0, screenWidth, screenHeight, gl);
    boolean found = false;
    for(int x = 0; x < 50 && !found; x++){
        for(int y = 0; y < 100 && !found; y++){
            int pixel = bmp.getPixel(x, y);
            if(pixel == Color.BLACK){
                cordinate = x;
                found=true;
            }
        }
    }
Bitmap bmp=SavePixels(0,0,屏幕宽度,屏幕高度,gl);
布尔值=false;
对于(int x=0;x<50&&!found;x++){
对于(int y=0;y<100&&!找到;y++){
int pixel=bmp.getPixel(x,y);
如果(像素==颜色.黑色){
cordinate=x;
发现=真;
}
}
}

您确定SavePixels(0、0、屏幕宽度、屏幕高度、gl)方法的结果吗?尝试将此位图保存到文件中,并检查其内部内容您的
位图是否正确?您是否尝试使用
color.RGBToHSV()
将ARGB颜色转换为HSV仅用于测试目的?是的,我将位图保存在设备上以确保没有空白图像。位图是正确的您需要查找第一个黑色像素的行还是列?我需要查找列