[英]get pixel color from bitmap android
我想檢查位圖部分中像素的顏色。 我需要確定黑色像素從什么位置開始。 這是我的實現。
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;
}
}
}
不幸的是,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;
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.