我想在触摸点正上方的放大的气球中显示触摸图像时选择的颜色。与使用逐项叠加显示我在地图中的当前位置类似。怎么能实现呢?
答案 0 :(得分:1)
int color = bitmap.getPixel((int)event.getX(),(int)event.getX());
RGB.setText(" R:"+Color.red(color)+" G:"+Color.green(color)+" B:"+Color.blue(color));
答案 1 :(得分:1)
这是一个非常好的问题,之前的答案需要通过此代码段进行更多解释:
imageView1 = (ImageView)findViewById(R.id.imageView1);
imageView1.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN){
int positionX = (int)event.getX();
int positionY = (int)event.getY();
Log.i("ON TOUCH COORDINATES","x: "+positionX + " y: " + positionY);
BitmapDrawable bd = (BitmapDrawable)imageView1.getDrawable();
Bitmap bitmap = bd.getBitmap();
int color_selected = bitmap.getPixel(positionX, positionY);
Log.i("COLOR SELECTED"," "+color_selected);
}
return true;
}
});