getValues ( )源码实例Demo

android.graphics.Matrix#getValues ( )源码实例Demo

下面列出了android.graphics.Matrix#getValues ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MiBandDecompiled   文件: ImageActivity.java
private void c()
{
    float f1 = q.width();
    Matrix matrix = e.getImageMatrix();
    float af[] = new float[9];
    matrix.getValues(af);
    float f2 = af[2];
    float f3 = af[5];
    float f4 = af[0];
    float f5 = (float)o / f1;
    int i1 = (int)(((float)q.left - f2) / f4);
    int j1 = (int)(((float)q.top - f3) / f4);
    Matrix matrix1 = new Matrix();
    matrix1.set(matrix);
    matrix1.postScale(f5, f5);
    int k1 = (int)(650F / f4);
    int l1 = Math.min(s.getWidth() - i1, k1);
    int i2 = Math.min(s.getHeight() - j1, k1);
    Bitmap bitmap = Bitmap.createBitmap(s, i1, j1, l1, i2, matrix1, true);
    Bitmap bitmap1 = Bitmap.createBitmap(bitmap, 0, 0, o, p);
    bitmap.recycle();
    a(bitmap1);
}
 
源代码2 项目: CrossMobile   文件: AndroidGraphicsBridge.java
@Override
public CGAffineTransform nativeToTarget(Matrix from, CGAffineTransform to) {
    float[] matrix = new float[9];
    from.getValues(matrix);
    if (to == null)
        to = new CGAffineTransform(matrix[0], matrix[3], matrix[1], matrix[4], matrix[2], matrix[5]);
    else {
        to.setA(matrix[0]);
        to.setB(matrix[3]);
        to.setC(matrix[1]);
        to.setD(matrix[4]);
        to.setTx(matrix[2]);
        to.setTy(matrix[5]);
    }
    return to;
}
 
源代码3 项目: ImagePicker   文件: PinchImageView.java
/**
 * 获取矩阵的缩放值
 *
 * @param matrix 要计算的矩阵
 * @return float[]{scaleX, scaleY}
 */
public static float[] getMatrixScale(Matrix matrix) {
    if (matrix != null) {
        float[] value = new float[9];
        matrix.getValues(value);
        return new float[]{value[0], value[4]};
    } else {
        return new float[2];
    }
}
 
源代码4 项目: TelePlus-Android   文件: GLMatrix.java
public static float[] LoadGraphicsMatrix(Matrix matrix) {
    float m[] = new float[16];
    float v[] = new float[9];
    matrix.getValues(v);

    m[0] = v[Matrix.MSCALE_X]; //m.a;
    m[1] = v[Matrix.MSKEW_X]; //m.b;
    m[2] = 0.0f;
    m[3] = 0.0f;

    m[4] = v[Matrix.MSKEW_Y]; //m.c;
    m[5] = v[Matrix.MSCALE_Y]; //m.d;
    m[6] = 0.0f;
    m[7] = 0.0f;

    m[8] = 0.0f;
    m[9] = 0.0f;
    m[10] = 1.0f;
    m[11] = 0.0f;

    m[12] = v[Matrix.MTRANS_X]; //m.tx;
    m[13] = v[Matrix.MTRANS_Y]; //m.ty;
    m[14] = 0.0f;
    m[15] = 1.0f;

    return m;
}
 
源代码5 项目: NetKnight   文件: ViewPortHandler.java
/**
 * limits the maximum scale and X translation of the given matrix
 *
 * @param matrix
 */
public void limitTransAndScale(Matrix matrix, RectF content) {

    matrix.getValues(matrixBuffer);

    float curTransX = matrixBuffer[Matrix.MTRANS_X];
    float curScaleX = matrixBuffer[Matrix.MSCALE_X];

    float curTransY = matrixBuffer[Matrix.MTRANS_Y];
    float curScaleY = matrixBuffer[Matrix.MSCALE_Y];

    // min scale-x is 1f
    mScaleX = Math.min(Math.max(mMinScaleX, curScaleX), mMaxScaleX);

    // min scale-y is 1f
    mScaleY = Math.min(Math.max(mMinScaleY, curScaleY), mMaxScaleY);

    float width = 0f;
    float height = 0f;

    if (content != null) {
        width = content.width();
        height = content.height();
    }

    float maxTransX = -width * (mScaleX - 1f);
    mTransX = Math.min(Math.max(curTransX, maxTransX - mTransOffsetX), mTransOffsetX);

    float maxTransY = height * (mScaleY - 1f);
    mTransY = Math.max(Math.min(curTransY, maxTransY + mTransOffsetY), -mTransOffsetY);

    matrixBuffer[Matrix.MTRANS_X] = mTransX;
    matrixBuffer[Matrix.MSCALE_X] = mScaleX;

    matrixBuffer[Matrix.MTRANS_Y] = mTransY;
    matrixBuffer[Matrix.MSCALE_Y] = mScaleY;

    matrix.setValues(matrixBuffer);
}
 
源代码6 项目: scene   文件: MatrixEvaluator.java
@Override
public Matrix evaluate(float fraction, Matrix startValue, Matrix endValue) {
    startValue.getValues(mTempStartValues);
    endValue.getValues(mTempEndValues);
    for (int i = 0; i < 9; i++) {
        float diff = mTempEndValues[i] - mTempStartValues[i];
        mTempEndValues[i] = mTempStartValues[i] + (fraction * diff);
    }
    mTempMatrix.setValues(mTempEndValues);

    return mTempMatrix;
}
 
private void adjustCanvasForBorder(Canvas canvas) {
    Matrix canvasMatrix = canvas.getMatrix();
    final float[] values = new float[9];
    canvasMatrix.getValues(values);

    final float scaleFactorX = values[0];
    final float scaleFactorY = values[4];
    final float translateX = values[2];
    final float translateY = values[5];

    final float newScaleX = mBounds.width()
            / (mBounds.width() + mBorderWidth + mBorderWidth);
    final float newScaleY = mBounds.height()
            / (mBounds.height() + mBorderWidth + mBorderWidth);

    canvas.scale(newScaleX, newScaleY);
    if (ScaleType.FIT_START == mScaleType || ScaleType.FIT_END == mScaleType
            || ScaleType.FIT_XY == mScaleType || ScaleType.FIT_CENTER == mScaleType
            || ScaleType.CENTER_INSIDE == mScaleType || ScaleType.MATRIX == mScaleType) {
        canvas.translate(mBorderWidth, mBorderWidth);
    } else if (ScaleType.CENTER == mScaleType || ScaleType.CENTER_CROP == mScaleType) {
        // First, make translate values to 0
        canvas.translate(
                -translateX / (newScaleX * scaleFactorX), 
                -translateY / (newScaleY * scaleFactorY));
        // Then, set the final translate values.
        canvas.translate(-(mBounds.left - mBorderWidth), -(mBounds.top - mBorderWidth));
    } 
}
 
源代码8 项目: mollyim-android   文件: AnimationMatrix.java
private AnimationMatrix(@NonNull Matrix undo, @NonNull Runnable invalidate) {
  this.invalidate = invalidate;
  this.canAnimate = true;
  undo.getValues(undoValues);
}
 
源代码9 项目: PhotoViewCropper   文件: ImageViewUtil.java
public static float getXTran(Matrix matrix){
    float[] f = new float[9];
    matrix.getValues(f);
    return f[Matrix.MTRANS_X];
}
 
源代码10 项目: LockDemo   文件: ImageViewTouchBase.java
protected float getValue(Matrix matrix, int whichValue) {
    matrix.getValues(matrixValues);
    return matrixValues[whichValue];
}
 
源代码11 项目: ImageChoose   文件: ScaleImageView.java
protected float getValue(Matrix matrix, int whichValue) {
    matrix.getValues(mMatrixValues);
    return mMatrixValues[whichValue];
}
 
源代码12 项目: Pi-Locker   文件: ImageViewTouchBase.java
protected float getValue(Matrix matrix, int whichValue) {

        matrix.getValues(mMatrixValues);
        return mMatrixValues[whichValue];
    }
 
源代码13 项目: AndroidDemo   文件: MatrixActivity.java
public boolean onTouch(View v, MotionEvent e) {
		if (e.getAction() == MotionEvent.ACTION_UP) {
			Matrix matrix = new Matrix();

//			// 1. 平移
//			matrix.postTranslate(view.getImageBitmap().getWidth(), view.getImageBitmap().getHeight());
//			// 在x方向平移view.getImageBitmap().getWidth(),在y轴方向view.getImageBitmap().getHeight()
//			view.setImageMatrix(matrix);

//			// 2. 旋转(围绕图像的中心点)
//			matrix.setRotate(45f, view.getImageBitmap().getWidth() / 2f, view.getImageBitmap().getHeight() / 2f);
//			// 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
//			matrix.postTranslate(view.getImageBitmap().getWidth() * 1.5f, 0f);
//			view.setImageMatrix(matrix);


			// 3. 旋转(围绕坐标原点) + 平移(效果同2)
//			matrix.setRotate(45f);
//			matrix.preTranslate(-1f * view.getImageBitmap().getWidth() / 2f, -1f * view.getImageBitmap().getHeight() / 2f);
//			matrix.postTranslate((float)view.getImageBitmap().getWidth() / 2f, (float)view.getImageBitmap().getHeight() / 2f);
//			// 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
//			matrix.postTranslate((float)view.getImageBitmap().getWidth() * 1.5f, 0f);
//			view.setImageMatrix(matrix);


			// 4. 缩放
//			matrix.setScale(2f, 2f);
//			// 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
//			matrix.postTranslate(view.getImageBitmap().getWidth(), view.getImageBitmap().getHeight());
//			view.setImageMatrix(matrix);


			// 5. 错切 - 水平
//			matrix.setSkew(1f, 0f);
//			// 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
//			matrix.postTranslate(view.getImageBitmap().getWidth(), 0f);
//			view.setImageMatrix(matrix);


//			// 6. 错切 - 垂直
//			matrix.setSkew(0f, 0.5f);
//			// 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
//			matrix.postTranslate(0f, view.getImageBitmap().getHeight());
//			view.setImageMatrix(matrix);


//			7. 错切 - 水平 + 垂直
//			matrix.setSkew(0.5f, 0.5f);
//			// 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
//			matrix.postTranslate(0f, view.getImageBitmap().getHeight());
//			view.setImageMatrix(matrix);

//			// 8. 对称 (水平对称)
			float matrix_values[] = {1f, 0f, 0f, 0f, -1f, 0f, 0f, 0f, 1f};
			matrix.setValues(matrix_values);
			// 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
			matrix.postTranslate(0f, view.getImageBitmap().getHeight() * 2f);
			view.setImageMatrix(matrix);

//			// 9. 对称 - 垂直
//			float matrix_values[] = {-1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f};
//			matrix.setValues(matrix_values);
//
//			// 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
//			matrix.postTranslate(view.getImageBitmap().getWidth() * 2f, 0f);
//			view.setImageMatrix(matrix);

//			// 10. 对称(对称轴为直线y = x)
//			float matrix_values[] = {0f, -1f, 0f, -1f, 0f, 0f, 0f, 0f, 1f};
//			matrix.setValues(matrix_values);
//
//			// 做下面的平移变换,纯粹是为了让变换后的图像和原图像不重叠
//			matrix.postTranslate(view.getImageBitmap().getHeight() + view.getImageBitmap().getWidth(),
//					view.getImageBitmap().getHeight() + view.getImageBitmap().getWidth());
//			view.setImageMatrix(matrix);

			// 下面的代码是为了查看matrix中的元素
			float[] matrixValues = new float[9];
			matrix.getValues(matrixValues);
			for(int i = 0; i < 3; ++i)
			{
				String temp = new String();
				for(int j = 0; j < 3; ++j)
				{
					temp += matrixValues[3 * i + j ] + "\t";
				}
				Log.e(TAG, temp);
			}

			view.invalidate();
		}
		return true;
	}
 
源代码14 项目: EasyPhotos   文件: TransformImageView.java
/**
 * This method returns Matrix value for given index.
 *
 * @param matrix     - valid Matrix object
 * @param valueIndex - index of needed value. See {@link Matrix#MSCALE_X} and others.
 * @return - matrix value for index
 */
protected float getMatrixValue(@NonNull Matrix matrix, @IntRange(from = 0, to = MATRIX_VALUES_COUNT) int valueIndex) {
    matrix.getValues(mMatrixValues);
    return mMatrixValues[valueIndex];
}
 
源代码15 项目: BigApp_Discuz_Android   文件: PhotoViewAttacher.java
/**
 * Helper method that 'unpacks' a Matrix and returns the required value
 *
 * @param matrix     - Matrix to unpack
 * @param whichValue - Which value from Matrix.M* to return
 * @return float - returned value
 */
private float getValue(Matrix matrix, int whichValue) {
    matrix.getValues(mMatrixValues);
    return mMatrixValues[whichValue];
}
 
源代码16 项目: AndroidPickPhotoDialog   文件: PhotoViewAttacher.java
/**
 * Helper method that 'unpacks' a Matrix and returns the required value
 *
 * @param matrix     - Matrix to unpack
 * @param whichValue - Which value from Matrix.M* to return
 * @return float - returned value
 */
private float getValue(Matrix matrix, int whichValue) {
    matrix.getValues(mMatrixValues);
    return mMatrixValues[whichValue];
}
 
源代码17 项目: Tweetin   文件: PhotoViewAttacher.java
/**
 * Helper method that 'unpacks' a Matrix and returns the required value
 *
 * @param matrix     - Matrix to unpack
 * @param whichValue - Which value from Matrix.M* to return
 * @return float - returned value
 */
private float getValue(Matrix matrix, int whichValue) {
    matrix.getValues(mMatrixValues);
    return mMatrixValues[whichValue];
}
 
源代码18 项目: UltimateAndroid   文件: PhotoViewAttacher.java
/**
 * Helper method that 'unpacks' a Matrix and returns the required value
 *
 * @param matrix     - Matrix to unpack
 * @param whichValue - Which value from Matrix.M* to return
 * @return float - returned value
 */
private float getValue(Matrix matrix, int whichValue) {
    matrix.getValues(mMatrixValues);
    return mMatrixValues[whichValue];
}
 
源代码19 项目: MNImageBrowser   文件: PhotoViewAttacher.java
/**
 * Helper method that 'unpacks' a Matrix and returns the required value
 *
 * @param matrix     Matrix to unpack
 * @param whichValue Which value from Matrix.M* to return
 * @return returned value
 */
private float getValue(Matrix matrix, int whichValue) {
    matrix.getValues(mMatrixValues);
    return mMatrixValues[whichValue];
}
 
源代码20 项目: PicturePicker   文件: PhotoViewAttacher.java
/**
 * Helper method that 'unpacks' a Matrix and returns the required value
 *
 * @param matrix     - Matrix to unpack
 * @param whichValue - Which value from Matrix.M* to return
 * @return float - returned value
 */
private float getValue(Matrix matrix, int whichValue) {
    matrix.getValues(mMatrixValues);
    return mMatrixValues[whichValue];
}