从图像中叠加的触摸事件中选择显示的颜色 [英] Showing color selected from an image on touch event in an overlay
本文介绍了从图像中叠加的触摸事件中选择显示的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示在放大的气球只是触摸点以上上的图像的触摸选择的颜色。类似的显示采用逐项叠加的地图我的当前位置。那怎么可以实现?
I want to display the color selected on touch of an image in an enlarged baloon just above the touch point . Similar to showing my current location in maps using itemized overlays. How can that be achieved ?
推荐答案
这是一个很好的问题和previous答案需要多一点的解释,这个code片段的方式:
This is a very good question and the previous answer needed a bit more explanation by way of this code snippet:
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;
}
});
这篇关于从图像中叠加的触摸事件中选择显示的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文