获取图片中某点的RGB值?

需求:触摸图片中的某一点就可以获取得这点的RGB值?
2025-01-04 11:10:34
推荐回答(3个)
回答1:

public int getPixel (int x, int y)Added in API level 1Returns the Color at the specified location. Throws an exception if x or y are out of bounds (negative or >= to the width or height respectively). The returned color is a non-premultiplied ARGB value.ParametersxThe x coordinate (0...width-1) of the pixel to returnyThe y coordinate (0...height-1) of the pixel to returnReturns[*]The argb Color at the specified coordinateThrowsIllegalArgumentExceptionif x, y exceed the bitmap's bounds

回答2:

public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub bitmap.getPixel(event.getX(), event.getY()); return false; }

回答3:

谢谢帮助!!!!