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


Java Matrix.setValues方法代码示例

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


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

示例1: fitScreen

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Resets all zooming and dragging and makes the chart fit exactly it's
 * bounds.  Output Matrix is available for those who wish to cache the object.
 */
public void fitScreen(Matrix outputMatrix) {
    mMinScaleX = 1f;
    mMinScaleY = 1f;

    outputMatrix.set(mMatrixTouch);

    float[] vals = valsBufferForFitScreen;
    for (int i = 0; i < 9; i++) {
        vals[i] = 0;
    }

    outputMatrix.getValues(vals);

    // reset all translations and scaling
    vals[Matrix.MTRANS_X] = 0f;
    vals[Matrix.MTRANS_Y] = 0f;
    vals[Matrix.MSCALE_X] = 1f;
    vals[Matrix.MSCALE_Y] = 1f;

    outputMatrix.setValues(vals);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ViewPortHandler.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: applyTransformation

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {

    mAnimRect.left = mStartCropWindowRect.left + (mEndCropWindowRect.left - mStartCropWindowRect.left) * interpolatedTime;
    mAnimRect.top = mStartCropWindowRect.top + (mEndCropWindowRect.top - mStartCropWindowRect.top) * interpolatedTime;
    mAnimRect.right = mStartCropWindowRect.right + (mEndCropWindowRect.right - mStartCropWindowRect.right) * interpolatedTime;
    mAnimRect.bottom = mStartCropWindowRect.bottom + (mEndCropWindowRect.bottom - mStartCropWindowRect.bottom) * interpolatedTime;
    mCropOverlayView.setCropWindowRect(mAnimRect);

    for (int i = 0; i < mAnimPoints.length; i++) {
        mAnimPoints[i] = mStartBoundPoints[i] + (mEndBoundPoints[i] - mStartBoundPoints[i]) * interpolatedTime;
    }
    mCropOverlayView.setBounds(mAnimPoints, mImageView.getWidth(), mImageView.getHeight());

    for (int i = 0; i < mAnimMatrix.length; i++) {
        mAnimMatrix[i] = mStartImageMatrix[i] + (mEndImageMatrix[i] - mStartImageMatrix[i]) * interpolatedTime;
    }
    Matrix m = mImageView.getImageMatrix();
    m.setValues(mAnimMatrix);
    mImageView.setImageMatrix(m);

    mImageView.invalidate();
    mCropOverlayView.invalidate();
}
 
开发者ID:garretyoder,项目名称:Cluttr,代码行数:25,代码来源:CropImageAnimation.java

示例4: setMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * set matrix for view
 *
 * @param values
 */
public LuaValue setMatrix(float values[]) {
    View view = getView();
    if (view != null) {
        try {
            Field field = View.class.getDeclaredField("mRenderNode");
            field.setAccessible(true);
            Object renderNode = field.get(view);
            Method method1 = renderNode.getClass().getDeclaredMethod("setAnimationMatrix", Matrix.class);

            Matrix matrix = new Matrix();
            matrix.reset();
            matrix.setValues(values);
            method1.invoke(renderNode, matrix);
        } catch (Exception e){
            e.printStackTrace();
        }
    }
    return this;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:25,代码来源:UDView.java

示例5: 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

示例6: 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

示例7: doInBackground

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected Bitmap doInBackground(Bitmap... params) {
    // System.out.println("保存贴图!");
    Matrix touchMatrix = mContext.mainImage.getImageViewMatrix();

    Bitmap resultBit = Bitmap.createBitmap(params[0]).copy(Bitmap.Config.ARGB_8888, true);
    resultBit.setHasAlpha(true);
    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());

    handleImage(canvas, m);

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

示例8: getSymmetricalMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 关于两个control连线的对称矩阵
 * @return
 */
private Matrix getSymmetricalMatrix() {
    // 根据网上资料,有一点错误,就是先-b,再b
    float k = (mBzControl1.y - mBzControl2.y) / (mBzControl1.x - mBzControl2.x);
    float[] values = new float[9];
    values[0] = -1 * (k * k - 1) / (k * k + 1);
    values[1] = 2 * k / (k * k + 1);
    values[3] = values[1];
    values[4] = -values[0];
    values[8] = 1;

    float b = mBzControl1.y - mBzControl1.x * k;
    Matrix matrix = new Matrix();
    matrix.setValues(values);
    matrix.preTranslate(0, -b);
    matrix.postTranslate(0, b);

    return matrix;
}
 
开发者ID:1014277960,项目名称:DailyReader,代码行数:23,代码来源:ReadView.java

示例9: 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

示例10: 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

示例11: setMatrixValue

import android.graphics.Matrix; //导入方法依赖的package包/类
public static void setMatrixValue(@NonNull Matrix matrix, @IntRange(from = 0, to = 8) int valueIndex, float value) {
    synchronized (lock) {
        matrix.getValues(matrixValues);
        matrixValues[valueIndex] = value;
        matrix.setValues(matrixValues);
    }
}
 
开发者ID:xyzxqs,项目名称:XphotoView,代码行数:8,代码来源:MatrixUtils.java

示例12: submit

import android.graphics.Matrix; //导入方法依赖的package包/类
private void submit() {
  getImageMatrix();
  Matrix matrix = new Matrix();
  matrix.setValues(mImageMatrix);
  mImageMatrixView.setImageAndMatrix(mBitmap, matrix);
  mImageMatrixView.invalidate();
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:8,代码来源:MatrixTestUI.java

示例13: reset

import android.graphics.Matrix; //导入方法依赖的package包/类
private void reset() {
  initImageMatrix();
  getImageMatrix();
  Matrix matrix = new Matrix();
  matrix.setValues(mImageMatrix);
  mImageMatrixView.setImageAndMatrix(mBitmap, matrix);
  mImageMatrixView.invalidate();
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:9,代码来源:MatrixTestUI.java

示例14: applyTransformation

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {

  mAnimRect.left =
      mStartCropWindowRect.left
          + (mEndCropWindowRect.left - mStartCropWindowRect.left) * interpolatedTime;
  mAnimRect.top =
      mStartCropWindowRect.top
          + (mEndCropWindowRect.top - mStartCropWindowRect.top) * interpolatedTime;
  mAnimRect.right =
      mStartCropWindowRect.right
          + (mEndCropWindowRect.right - mStartCropWindowRect.right) * interpolatedTime;
  mAnimRect.bottom =
      mStartCropWindowRect.bottom
          + (mEndCropWindowRect.bottom - mStartCropWindowRect.bottom) * interpolatedTime;
  mCropOverlayView.setCropWindowRect(mAnimRect);

  for (int i = 0; i < mAnimPoints.length; i++) {
    mAnimPoints[i] =
        mStartBoundPoints[i] + (mEndBoundPoints[i] - mStartBoundPoints[i]) * interpolatedTime;
  }
  mCropOverlayView.setBounds(mAnimPoints, mImageView.getWidth(), mImageView.getHeight());

  for (int i = 0; i < mAnimMatrix.length; i++) {
    mAnimMatrix[i] =
        mStartImageMatrix[i] + (mEndImageMatrix[i] - mStartImageMatrix[i]) * interpolatedTime;
  }
  Matrix m = mImageView.getImageMatrix();
  m.setValues(mAnimMatrix);
  mImageView.setImageMatrix(m);

  mImageView.invalidate();
  mCropOverlayView.invalidate();
}
 
开发者ID:prashantsaini1,项目名称:android-titanium-imagecropper,代码行数:35,代码来源:CropImageAnimation.java

示例15: calculateInterpolation

import android.graphics.Matrix; //导入方法依赖的package包/类
protected void calculateInterpolation(Matrix outMatrix, float fraction) {
  for (int i = 0; i < 9; i++) {
    mCurrentValues[i] = (1 - fraction) * mStartValues[i] + fraction * mStopValues[i];
  }
  outMatrix.setValues(mCurrentValues);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:AbstractAnimatedZoomableController.java


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