当前位置: 首页>>代码示例>>Java>>正文


Java Matrix.getValues方法代码示例

本文整理汇总了Java中android.graphics.Matrix.getValues方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.getValues方法的具体用法?Java Matrix.getValues怎么用?Java Matrix.getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Matrix的用法示例。


在下文中一共展示了Matrix.getValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canScroll

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if(v instanceof ImageView) {
        ImageView iv = (ImageView) v;
        Drawable drawable = iv.getDrawable();
        if(drawable != null) {
            float vw = iv.getWidth();
            float vh = iv.getHeight();
            float dw = drawable.getIntrinsicWidth();
            float dh = drawable.getIntrinsicHeight();

            Matrix matrix = iv.getImageMatrix();
            matrix.getValues(VALUES);
            float tx = VALUES[Matrix.MTRANS_X] + dx;
            float sdw = dw * VALUES[Matrix.MSCALE_X];

            //Log.d(TAG, "sdw: " + sdw + " vw: " + vw);

            return VALUES[Matrix.MSCALE_X] / centerInsideScale(vw, vh, dw, dh) > scaleThreshold && !translationExceedsBoundary(tx, vw, sdw) && sdw > vw && pointerCount == 1; // Assumes x-y scales are equal
        }
    }
    return super.canScroll(v, checkV, dx, x, y);
}
 
开发者ID:martinwithaar,项目名称:PinchToZoom,代码行数:24,代码来源:ImageViewPager.java

示例2: getTransform

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
public Matrix getTransform(
    Matrix transform,
    Rect parentBounds,
    int childWidth,
    int childHeight,
    float focusX,
    float focusY) {
  Rect boundsFrom = (mBoundsFrom != null) ? mBoundsFrom : parentBounds;
  Rect boundsTo = (mBoundsTo != null) ? mBoundsTo : parentBounds;

  mScaleTypeFrom.getTransform(transform, boundsFrom, childWidth, childHeight, focusX, focusY);
  transform.getValues(mMatrixValuesFrom);
  mScaleTypeTo.getTransform(transform, boundsTo, childWidth, childHeight, focusX, focusY);
  transform.getValues(mMatrixValuesTo);

  for (int i = 0; i < 9; i++) {
    mMatrixValuesInterpolated[i] = mMatrixValuesFrom[i] * (1 - mInterpolatingValue) +
        mMatrixValuesTo[i] * mInterpolatingValue;
  }
  transform.setValues(mMatrixValuesInterpolated);
  return transform;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:ScalingUtils.java

示例3: restoreBitmap

import android.graphics.Matrix; //导入方法依赖的package包/类
public static Bitmap restoreBitmap(Bitmap src, Matrix matrix, int w, int h) {
    Bitmap result = Bitmap.createBitmap(w, h, src.getConfig());
    result.setDensity(src.getDensity());
    Canvas canvas = new Canvas(result);
    float[] data = new float[9];
    matrix.getValues(data);// 底部图片变化记录矩阵原始数据
    Matrix3 cal = new Matrix3(data);// 辅助矩阵计算类
    Matrix3 inverseMatrix = cal.inverseMatrix();// 计算逆矩阵
    Matrix m = new Matrix();
    m.setValues(inverseMatrix.getValues());
    float[] f = new float[9];
    m.getValues(f);
    int dx = (int) f[Matrix.MTRANS_X];
    int dy = (int) f[Matrix.MTRANS_Y];
    float scale_x = f[Matrix.MSCALE_X];
    float scale_y = f[Matrix.MSCALE_Y];
    canvas.save();
    canvas.translate(dx, dy);
    canvas.scale(scale_x, scale_y);
    canvas.drawBitmap(src, 0, 0, null);
    canvas.restore();
    return result;
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:24,代码来源:BitmapUtils.java

示例4: doInBackground

import android.graphics.Matrix; //导入方法依赖的package包/类
@SuppressWarnings("WrongThread")
   @Override
   protected Bitmap doInBackground(Bitmap... params) {
       RectF cropRect = mCropPanel.getCropRect();// 剪切区域矩形
       Matrix touchMatrix = activity.mainImage.getImageViewMatrix();
       // Canvas canvas = new Canvas(resultBit);
       float[] data = new float[9];
       touchMatrix.getValues(data);// 底部图片变化记录矩阵原始数据
       Matrix3 cal = new Matrix3(data);// 辅助矩阵计算类
       Matrix3 inverseMatrix = cal.inverseMatrix();// 计算逆矩阵
       Matrix m = new Matrix();
       m.setValues(inverseMatrix.getValues());
       m.mapRect(cropRect);// 变化剪切矩形

       // Paint paint = new Paint();
       // paint.setColor(Color.RED);
       // paint.setStrokeWidth(10);
       // canvas.drawRect(cropRect, paint);
       // Bitmap resultBit = Bitmap.createBitmap(params[0]).copy(
       // Bitmap.Config.ARGB_8888, true);
       Bitmap resultBit = Bitmap.createBitmap(params[0], (int) cropRect.left, (int) cropRect
.top, (int) cropRect.width(), (int) cropRect.height());

       //saveBitmap(resultBit, activity.saveFilePath);
       return resultBit;
   }
 
开发者ID:viseator,项目名称:MontageCam,代码行数:27,代码来源:CropFragment.java

示例5: calcTextSizeForRect

import android.graphics.Matrix; //导入方法依赖的package包/类
private static float calcTextSizeForRect(String _text, Paint _textPaint, RectF _rectBounds) {

        Matrix matrix = new Matrix();
        Rect textBoundsTmp = new Rect();
        //replace ones because for some fonts the 1 takes less space which causes issues
        String text = _text.replace('1', '0');

        //get current mText bounds
        _textPaint.getTextBounds(text, 0, text.length(), textBoundsTmp);

        RectF textBoundsTmpF = new RectF(textBoundsTmp);

        matrix.setRectToRect(textBoundsTmpF, _rectBounds, Matrix.ScaleToFit.CENTER);
        float values[] = new float[9];
        matrix.getValues(values);
        return _textPaint.getTextSize() * values[Matrix.MSCALE_X];
    }
 
开发者ID:VRLoser,项目名称:greendao_expand,代码行数:18,代码来源:CircleProgressView.java

示例6: getMatrixScale

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 获取矩阵的缩放值
 *
 * @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];
    }
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:16,代码来源:PinchImageView.java

示例7: limitTransAndScale

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:ViewPortHandler.java

示例8: applyScaleToRadii

import android.graphics.Matrix; //导入方法依赖的package包/类
private void applyScaleToRadii(Matrix m) {
    float[] values = new float[9];
    m.getValues(values);
    for (int i = 0; i < mRadii.length; i++) {
        mRadii[i] = mRadii[i] / values[0];
    }
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:8,代码来源:SelectableRoundedImageView.java

示例9: applyTransformation

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    final float fromDegrees = mFromDegrees;
    float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
    final float centerX = mCenterX;
    final float centerY = mCenterY;
    final Camera camera = mCamera;
    final Matrix matrix = t.getMatrix();
    camera.save();

    // 调节深度
    if (mReverse)
        camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
    else
        camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime));

    // 绕y轴旋转
    camera.rotateY(degrees);
    camera.getMatrix(matrix);
    camera.restore();

    // 修正失真,主要修改 MPERSP_0 和 MPERSP_1
    float[] mValues = new float[9];
    matrix.getValues(mValues);              //获取数值
    mValues[6] = mValues[6] / scale;        //数值修正
    mValues[7] = mValues[7] / scale;        //数值修正
    matrix.setValues(mValues);              //重新赋值

    // 调节中心点
    matrix.preTranslate(-centerX, -centerY);
    matrix.postScale(centerX, centerY);

}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:34,代码来源:Rotate3DAnimation.java

示例10: getScale

import android.graphics.Matrix; //导入方法依赖的package包/类
public static float[] getScale(Matrix matrix) {
    float[] points = new float[9];
    matrix.getValues(points);
    return new float[]{points[0], points[4]};
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:6,代码来源:MatrixUtils.java

示例11: getValue

import android.graphics.Matrix; //导入方法依赖的package包/类
protected float getValue(Matrix matrix, int whichValue) {
    matrix.getValues(mMatrixValues);
    return mMatrixValues[whichValue];
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:5,代码来源:ImageViewTouchBase.java

示例12: setEndState

import android.graphics.Matrix; //导入方法依赖的package包/类
public void setEndState(float[] boundPoints, Matrix imageMatrix) {
  System.arraycopy(boundPoints, 0, mEndBoundPoints, 0, 8);
  mEndCropWindowRect.set(mCropOverlayView.getCropWindowRect());
  imageMatrix.getValues(mEndImageMatrix);
}
 
开发者ID:prashantsaini1,项目名称:android-titanium-imagecropper,代码行数:6,代码来源:CropImageAnimation.java

示例13: setEndState

import android.graphics.Matrix; //导入方法依赖的package包/类
public void setEndState(float[] boundPoints, Matrix imageMatrix) {
    System.arraycopy(boundPoints, 0, mEndBoundPoints, 0, 8);
    mEndCropWindowRect.set(mCropOverlayView.getCropWindowRect());
    imageMatrix.getValues(mEndImageMatrix);
}
 
开发者ID:chuch0805,项目名称:Android-Demo_ImageCroper,代码行数:6,代码来源:CropImageAnimation.java

示例14: getMatrixTranslateY

import android.graphics.Matrix; //导入方法依赖的package包/类
private float getMatrixTranslateY(Matrix transform) {
    transform.getValues(mTempValues);
    return mTempValues[Matrix.MTRANS_Y];
}
 
开发者ID:ibosong,项目名称:CommentGallery,代码行数:5,代码来源:DefaultZoomableController.java

示例15: getMatrixScaleFactor

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Gets the scale factor for the given matrix.
 * This method assumes the equal scaling factor for X and Y axis.
 */
private float getMatrixScaleFactor(Matrix transform) {
  transform.getValues(mTempValues);
  return mTempValues[Matrix.MSCALE_X];
}
 
开发者ID:idisfkj,项目名称:Zoomable,代码行数:9,代码来源:DefaultZoomableController.java


注:本文中的android.graphics.Matrix.getValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。