【问题标题】:Selected pixel of displayed image?显示图像的选定像素?
【发布时间】:2014-05-28 20:48:31
【问题描述】:

我正在显示的图像视图中选择图像的某些区域。然后我对显示在imageview中的那个位图的选定像素做一些工作。但我无法击中用户选择的那些像素。我知道我必须对显示的图像和实际位图进行一些像素映射。查看图片以更好地了解我的问题。

用户使用圆形选择器选择一些像素

处理后受影响的像素与用户选择的不同

我已经尝试过类似的方法来获得准确的像素

Bitmap image = EyeColorChangerActivity.getImageBitmap();

     int displayedwidht = image.getWidth();
     int displayedheight = image.getHeight();

     x = x*((float)displayedwidht/mScreenWidth);
     y = y*((float)displayedheight/mScreenHeight);

【问题讨论】:

  • 你想达到什么目的?
  • 我想改变选定像素的颜色

标签: android image bitmap


【解决方案1】:

在 ImageView 上设置 OnTouchListener。

在 OnTouchListener 的 onTouch 方法中使用下面的代码来获取选中的位图像素。

@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
int x = (int) arg1.getX();
int y = (int)arg1.getY();
int pixel = mBitmap.getPixel(x, y);
// process new color for selected pixel.
    ....
//set new color to bitmap pixel

return false;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-12
    • 2017-11-29
    • 1970-01-01
    • 2016-03-18
    • 1970-01-01
    • 2022-11-18
    相关资源
    最近更新 更多