我有一个代码,它采用位图并将X和Y坐标转换为RGB:
int pixel = bitmap.getPixel((int)x,(int) y);
inRed = Color.red(pixel);
inBlue = Color.blue(pixel);
inGreen = Color.green(pixel);
如何转换给定的RGB并获取位图中的X和Y坐标?
答案 0 :(得分:1)
使用给定的颜色查找位图中的第一个像素:
int color = // your color
int x, y; // used for output
boolean found = false;
for (int ix = 0; ix < bitmap.getWidth(); ++ix) {
for (int iy = 0; iy < bitmap.getHeight(); ++iy) {
if (color == bitmap.getPixel(ix, iy) {
found = true;
x = ix;
y = iy;
break;
}
}
}