本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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];
}
示例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];
}
}
示例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);
}
示例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];
}
}
示例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);
}
示例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]};
}
示例11: getValue
import android.graphics.Matrix; //导入方法依赖的package包/类
protected float getValue(Matrix matrix, int whichValue) {
matrix.getValues(mMatrixValues);
return mMatrixValues[whichValue];
}
示例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);
}
示例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);
}
示例14: getMatrixTranslateY
import android.graphics.Matrix; //导入方法依赖的package包/类
private float getMatrixTranslateY(Matrix transform) {
transform.getValues(mTempValues);
return mTempValues[Matrix.MTRANS_Y];
}
示例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];
}