[英]Detecting a color in a BitMap by touch
Is it possible to detect on color touch
with Bitmap
on 'Android'? 是否可以使用“ Android”上的
Bitmap
检测彩色touch
?
The screen will look like this: 屏幕将如下所示:
The black arrow
is the Bitmap
object that user can move up and down. black arrow
是用户可以上下移动的Bitmap
对象。 It should detect when black arrow is touching the blue line and add points for each second
that it has touched the line. 它应该检测到黑色箭头何时触及蓝线,并为触及蓝线的每一
second
添加点。
Maybe it is worth noting that arrow can be only moved up and down and the blue lines are what are moving from right to left. 也许值得注意的是,箭头只能上下移动,而蓝线是从右向左移动的线。
There is a wierd background and the background may contain blue since it will be a camera preview screen and the Canvas
where the arrow and the blue line are moving will be transparent. 有一个奇怪的背景,并且背景可能包含蓝色,因为它将是相机预览屏幕,并且箭头和蓝线移动的“
Canvas
将是透明的。 Will that be an issue or is there maybe a better way to detect collision? 这将是一个问题还是也许有更好的方法来检测碰撞?
The most important part that I need here is to detect 'collision' or weather the bitmap and the line are touching or not but the second part of the question would be, is there a way to add an animation or something that would show the user that the lines are touching, maybe chaing the arrow for a golden one or something. 我在这里需要的最重要的部分是检测“碰撞”或天气位图和线条是否接触,但问题的第二部分是,是否可以添加动画或向用户显示的内容线条触碰到的地方,也许是追着箭头寻找金色的东西。
The line is made with 'GraphView' and thus I can not really treat that as an 'object'. 该行是用“ GraphView”制作的,因此我不能真正将其视为“对象”。 More about graphview - http://www.android-graphview.org/
更多关于graphview - http://www.android-graphview.org/
If there is any need for source code then I can provide that but I'd rather not share it right off the bat. 如果需要任何源代码,那么我可以提供,但是我不希望立即分享。
EDIT I have tried using Pixels and detecting color that way but I have not gotten it to work. 编辑我曾尝试使用像素并以这种方式检测颜色,但我没有使它起作用。
For a given pixel, x and y: 对于给定的像素,x和y:
ImageView imageView = (ImageView)v;
Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
int pixel = bitmap.getPixel(x,y);
int redValue = Color.red(pixel);
int blueValue = Color.blue(pixel);
int greenValue = Color.green(pixel);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.