我有一个代码,它采用位图并将 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 坐标?
最佳答案
要查找位图中具有给定颜色的第一个像素:
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;
}
}
}
关于java - 将 RGB 转换为位图中的 X 和 Y,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21692813/