【问题标题】:Get rgb value of image when user clicked on image用户点击图片时获取图片的rgb值
【发布时间】:2012-03-14 10:51:38
【问题描述】:

我正在创建一个地图应用程序。当用户单击图像时,我需要获取图像的 RGB 值。 图片在ImageView

请帮忙。

【问题讨论】:

  • -1 表示没有研究工作,也没有自己尝试过。
  • @alextsc 他今天只加入了 SO。他需要通过stackoverflow.com/faq

标签: android


【解决方案1】:
int ColorCode = imageView.getDrawingCache().getPixel(x, y);

//这里x,y是坐标

这是link

【讨论】:

  • 你检查了我提供的链接吗?
  • 我检查了....代码很好,但不适合我的目的。在我的应用程序中,用户单击图像,需要该特定像素的 rgb 值来切换大小写。(没有固定位置和颜色)
【解决方案2】:
Bitmap bitmap = ((BitmapDrawable)imageView.getBackground()).getBitmap();  
int pixel = bitmap.getPixel(xCordinate,yCordinate);  
int redValue = Color.red(pixel);  
int blueValue = Color.blue(pixel);  
int greenValue = Color.green(pixel);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-06
    • 2020-04-14
    • 1970-01-01
    • 2010-09-06
    • 1970-01-01
    • 2016-07-21
    • 2018-03-22
    • 2012-02-27
    相关资源
    最近更新 更多