首页 > 解决方案 > 如何在图像上放置切换输入点?

问题描述

我正在制作一个 android 应用程序,我希望用户在其中点击图像并显示一个 blob 并将这些点存储在数据库中。与下图非常相似

附图片

从另一个应用程序。关于可以做什么的任何想法?它是覆盖在另一张图片上还是什么?

标签: android

解决方案


您可以从图像中识别颜色并检查颜色,如果您单击图像时选择特定颜色代码并检查预定义颜色,如果匹配则执行您的操作。

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
    }

推荐阅读