Hi I want to get pixel color when i touch image view , this code is working fine when width and height of image view in xml is wrap content

```
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight=".2"
        android:orientation="vertical" 
        android:gravity="center">

        <ImageView
            android:id="@+id/iv_cam"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher" >
        </ImageView>
    </LinearLayout>

```

, problem arises when in xml file i set width and height of image view wrap content to match parent

```
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight=".2"
        android:orientation="vertical" 
        android:gravity="center">

        <ImageView
            android:id="@+id/iv_cam"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/ic_launcher" >
        </ImageView>
    </LinearLayout>

```

by doing this small images become stretch
error comes 
E/MessageQueue-JNI(1006): java.lang.IllegalArgumentException: x must be < bitmap.width()

how can i solve this ...

@Override
 public boolean onTouch(View v, MotionEvent event) {

```
    if(event.getAction() == MotionEvent.ACTION_DOWN){           

    ImageView iv = ((ImageView)v);      
    Bitmap bmp = ((BitmapDrawable)iv.getDrawable()).getBitmap();

    int pixel = bmp.getPixel((int)event.getX(),(int)event.getY());// error comes in this line
    int alphaValue = Color.alpha(pixel);
    int redValue = Color.red(pixel);
    int blueValue = Color.blue(pixel);
    int greenValue = Color.green(pixel);

    Toast.makeText(this,"[" +alphaValue+"," +redValue+","+greenValue+","+blueValue+"]", Toast.LENGTH_LONG).show();

    }

    return false;
}

```