我有一个缩放的图像视图,当我们缩放并点击图像时我想获得图像的颜色怎么可能
答案 0 :(得分:0)
@ Talha_Sheikh918请检查,
使用此库可帮助您满足您的要求
https://github.com/chrisbanes/PhotoView
像这样使用
your_activity.xml
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/photo_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
YourActivity.java
PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
photoView.setImageResource(R.drawable.image);
功能强>
修改强>
如果你想获得指向像素的颜色。
PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
Bitmap bitmap = ((BitmapDrawable)photoView.getDrawable()).getBitmap();
imageView.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event){
int x = (int)event.getX();
int y = (int)event.getY();
int pixel = bitmap.getPixel(x,y);
//the pixel data
int redValue = Color.red(pixel);
int blueValue = Color.blue(pixel);
int greenValue = Color.green(pixel);
return false;
}
});