Get color of pixel in a scaled ImageView / Get ScaleFactor
<p>I want to add a color picker in my app and added an ImageView to the layout:</p>

<pre><code>&lt;ImageView
        android:id="@+id/img_colorpicker"
        android:adjustViewBounds="false"
        android:cropToPadding="false"
        app:srcCompat="@drawable/color_picker"
        android:scaleType="fitXY"
        android:layout_width="wrap_content"
        android:layout_height="200dp"
        android:layout_weight="0.06" /&gt;
</code></pre>

<p>The following code should return the colors of the pixel, when the user touches on it:</p>

<pre><code>img_colorpicker.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            int[] viewCoords = new int[2];
            img_colorpicker.getLocationOnScreen(viewCoords);
            int touchX = (int) event.getX();
            int touchY = (int) event.getY();

            System.out.println(touchX + "-" + touchY);
            int imageX = touchX - viewCoords[0]; 
            int imageY = touchY - viewCoords[1]; 

            Bitmap bitmap = ((BitmapDrawable)img_colorpicker.getDrawable()).getBitmap();
            int pixel = bitmap.getPixel(touchX,touchY);
            int redValue = Color.red(pixel); // I want these Values
            int greenValue = Color.green(pixel); // I want these Values
            int blueValue = Color.blue(pixel); // I want these Values



            return false;
        }
    });
</code></pre>

<p><strong>I think the bitmap has the real image size (2002 x 1127) so the calculated touch values are not correct...
I need to find out the scale factor of the bitmap.</strong></p>

<p>img_colorpicker.getScaleX(); -> returns 1</p>