android - 如何在图像上放置切换输入点?
问题描述
我正在制作一个 android 应用程序,我希望用户在其中点击图像并显示一个 blob 并将这些点存储在数据库中。与下图非常相似
从另一个应用程序。关于可以做什么的任何想法?它是覆盖在另一张图片上还是什么?
解决方案
您可以从图像中识别颜色并检查颜色,如果您单击图像时选择特定颜色代码并检查预定义颜色,如果匹配则执行您的操作。
Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();
int pixel = bitmap.getPixel(x,y); // x and y are coordinates
int redValue = Color.red(pixel);
int blueValue = Color.blue(pixel);
int greenValue = Color.green(pixel);
if(pixel == Color.RED){
// color is red
}
推荐阅读
- java - 在一个字符串中多次匹配一个模式
- r - 在纯素函数中使用并行处理?
- javascript - JavaScript this 内部函数对象
- python - 使用reduce()查找列表中最大值的变化次数(Python)
- javascript - 在javascript中使用多个条件过滤数组
- javafx - 在 JavaFx 程序中查看 PDF 文档
- oracle - 使用 SQL 加载器加载 .tsv
- c# - 我如何一次将 asp .net 中的邮件消息发送到多个地址(地址、主题、每个邮件的正文唯一)
- java - 如何将字符串中每个单词的首字母大写?
- sql - cs50 题集 7 的这条 SQL 语句有什么问题?