旋转图像时如何检测图像的哪一部分已被触摸? [英] How to detect which part of an image has been touched, when image is rotated?

查看:94
本文介绍了旋转图像时如何检测图像的哪一部分已被触摸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张这样的图片.我可以使用​​此代码对其进行旋转.现在,我想知道与轮盘的位置无关的触摸了哪种颜色.例如,无论车轮处于以下哪个位置,我都应该能够检测到我触摸过的颜色...红色,黄色,绿色,蓝色,粉红色或灰色.

I have an image like this one. I can rotate it using this code. Now I would like to know, which color has been touched, independently of the wheel's position. For example, whatever of the following positions the wheel is in, I should be able to detect what color I have touched ...red, yellow, green,blue,pink or grey.

有可能吗?我该怎么办?

Is it possible? How can I do it?

除了使用单张图片,还有其他可能性吗?(我希望避免使用此解决方案...)

Is there any other possibility instead of using a single picture?(solution I would prefer to avoid...)

或或或其他...

更新:我发布了一些颜色,因为我想更加清晰,为此我找到了解决方案,但是如果我有不同的图像而不是颜色,该怎么办.

UPDATE: I post some colors because I wanted to be more clear, and I got a solution for this, but how could I do if I have different images instead of a color.

推荐答案

解码x&触摸事件的y位置,然后在位图上调用getPixel: http://developer.android.com/reference/android/graphics/Bitmap.html

Decode the x & y position of the touch event then call getPixel on the Bitmap: http://developer.android.com/reference/android/graphics/Bitmap.html

这篇关于旋转图像时如何检测图像的哪一部分已被触摸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆