List of usage examples for android.graphics Matrix MSCALE_X
int MSCALE_X
To view the source code for android.graphics Matrix MSCALE_X.
Click Source Link
From source file:com.github.colorchief.colorchief.MainActivity.java
private int[] clickImagePixelLocation(int x, int y, ImageView imageView) { int[] pixelLocation = new int[2]; //ImageView imageViewer = (ImageView) findViewById(R.id.imageView); //Bitmap bitmap = null; //Drawable displayedDrawable = null; int bitmapWidth; int bitmapHeight; try {//from w w w .j a va 2 s.c o m //bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); bitmapWidth = bitmapScaledOriginal.getWidth(); bitmapHeight = bitmapScaledOriginal.getHeight(); } catch (NullPointerException npe) { Log.e(TAG, "Failed to extract Bitmap from ImageView or " + "access width and height parameters: " + npe); pixelLocation[0] = pixelLocation[1] = 0; return pixelLocation; } float[] imageMatrixValues = new float[9]; imageView.getImageMatrix().getValues(imageMatrixValues); float scaleX = imageMatrixValues[Matrix.MSCALE_X]; float scaleY = imageMatrixValues[Matrix.MSCALE_Y]; int[] imageViewerLoc = new int[2]; imageView.getLocationOnScreen(imageViewerLoc); //assuming Bitmap is centred in imageViewer int xOffsetBitmap2imageViewer = (imageView.getWidth() - Math.round(bitmapWidth * scaleX)) / 2; int yOffsetBitmap2imageViewer = (imageView.getHeight() - Math.round(bitmapHeight * scaleY)) / 2; // get total bitmap offset vs. screen origin int xTotalOffset = imageViewerLoc[0] + xOffsetBitmap2imageViewer; int yTotalOffset = imageViewerLoc[1] + yOffsetBitmap2imageViewer; int xLocationScaledBitmap = x - xTotalOffset; int yLocationScaledBitmap = y - yTotalOffset; pixelLocation[0] = Math.round(xLocationScaledBitmap / scaleX); pixelLocation[1] = Math.round(yLocationScaledBitmap / scaleY); Log.d(TAG, "Pixel location x,y = " + Integer.toString(pixelLocation[0]) + ", " + Integer.toString(pixelLocation[1])); if (pixelLocation[0] < 0) pixelLocation[0] = 0; if (pixelLocation[0] > (bitmapWidth - 1)) pixelLocation[0] = (bitmapWidth - 1); if (pixelLocation[1] < 0) pixelLocation[1] = 0; if (pixelLocation[1] > (bitmapHeight - 1)) pixelLocation[1] = (bitmapHeight - 1); return pixelLocation; }
From source file:com.jsibbold.zoomage.ZoomageView.java
@Override public boolean onScaleBegin(ScaleGestureDetector detector) { startScale = mValues[Matrix.MSCALE_X]; return true; }
From source file:com.android.volley.ui.PhotoView.java
/** * Returns the currently applied scale factor for the image. * <p>/*from w w w .j av a 2s . c o m*/ * NOTE: This method overwrites any values stored in {@link #mValues}. */ private float getScale() { return (float) Math.sqrt((float) Math.pow(getValue(mMatrix, Matrix.MSCALE_X), 2) + (float) Math.pow(getValue(mMatrix, Matrix.MSKEW_Y), 2)); }
From source file:com.androidex.volley.ui.PhotoView.java
/** * Returns the currently applied scale factor for the image. * <p>/*from w w w. j a v a2 s.com*/ * NOTE: This method overwrites any values stored in {@link #mValues}. */ private float getScale() { return FloatMath.sqrt((float) Math.pow(getValue(mMatrix, Matrix.MSCALE_X), 2) + (float) Math.pow(getValue(mMatrix, Matrix.MSKEW_Y), 2)); }
From source file:cl.monsoon.s1next.widget.PhotoView.java
/** * Returns the currently applied scale factor for the image. * <p>//from www .j a v a2 s. co m * NOTE: This method overwrites any values stored in {@link #mValues}. */ private float getScale() { mMatrix.getValues(mValues); return mValues[Matrix.MSCALE_X]; }