本文整理汇总了Java中android.graphics.Matrix.MSCALE_Y属性的典型用法代码示例。如果您正苦于以下问题:Java Matrix.MSCALE_Y属性的具体用法?Java Matrix.MSCALE_Y怎么用?Java Matrix.MSCALE_Y使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.graphics.Matrix
的用法示例。
在下文中一共展示了Matrix.MSCALE_Y属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertTargetInfo
void convertTargetInfo(ImageView tarView, Context context) {
if (tarView == null || tarView.getDrawable() == null) {
throw new NullPointerException("target ImageView or ImageView drawable must not null");
}
//get target ImageView info
tarView.getImageMatrix().getValues(mTargetValues);
Rect tarRect = tarView.getDrawable().getBounds();
mTargetWidth = (int) (tarRect.width() * mTargetValues[Matrix.MSCALE_X]);
mTargetHeight = (int) (tarRect.height() * mTargetValues[Matrix.MSCALE_Y]);
mTargetViewWidth = tarView.getWidth();
mTargetViewHeight = tarView.getHeight();
tarView.getLocationOnScreen(mTargetLocation);
init(context);
}
示例2: fitScreen
/**
* 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);
}
示例3: reSetMatrix
/**
* 重置Matrix
*/
private void reSetMatrix() {
if(checkRest()){
mCurrentMatrix.set(mMatrix);
setImageMatrix(mCurrentMatrix);
}else {
//判断Y轴是否需要更正
float[] values=new float[9];
getImageMatrix().getValues(values);
float height=mImageHeight*values[Matrix.MSCALE_Y];
if(height<getHeight()){
//在图片真实高度小于容器高度时,Y轴居中,Y轴理想偏移量为两者高度差/2,
float topMargin=(getHeight()-height)/2;
if(topMargin!=values[Matrix.MTRANS_Y]){
mCurrentMatrix.set(getImageMatrix());
mCurrentMatrix.postTranslate(0, topMargin-values[Matrix.MTRANS_Y]);
setImageMatrix(mCurrentMatrix);
}
}
}
}
示例4: handleImage
@Override
public void handleImage(Canvas canvas, Matrix m) {
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);
//System.out.println("scale = " + scale_x + " " + scale_y + " " + dx + "
// " + dy);
mTextStickerView.drawText(canvas, mTextStickerView.layout_x, mTextStickerView
.layout_y, mTextStickerView.mScale, mTextStickerView.mRotateAngle);
canvas.restore();
}
示例5: handleImage
@Override
public void handleImage(Canvas canvas, Matrix m) {
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.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
canvas.save();
canvas.translate(dx, dy);
canvas.scale(scale_x, scale_y);
if (mHollowView.getPaintBit() != null) {
canvas.drawBitmap(mHollowView.getPaintBit(), 0, 0, null);
}
canvas.restore();
}
示例6: handleImage
@Override
public void handleImage(Canvas canvas, Matrix m) {
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);
if (mPaintView.getPaintBit() != null) {
canvas.drawBitmap(mPaintView.getPaintBit(), 0, 0, null);
}
canvas.restore();
}
示例7: restoreBitmap
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;
}
示例8: convertOriginalInfo
public void convertOriginalInfo(ImageView oriView) {
if (oriView == null || oriView.getDrawable() == null) {
throw new NullPointerException("original ImageView or ImageView drawable must not null");
}
//get original ImageView info
oriView.getImageMatrix().getValues(mOriginalValues);
Rect oriRect = oriView.getDrawable().getBounds();
mOriginalWidth = (int) (oriRect.width() * mOriginalValues[Matrix.MSCALE_X]);
mOriginalHeight = (int) (oriRect.height() * mOriginalValues[Matrix.MSCALE_Y]);
mOriginalViewWidth = oriView.getWidth();
mOriginalViewHeight = oriView.getHeight();
oriView.getLocationOnScreen(mOriginalLocation);
}
示例9: onFling
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (mode == DRAG) {
if (flingDuration > 0 && !isAnimating()) {
float factor = ((float) flingDuration / 1000f) * flingExaggeration;
float[] values = corrector.getValues();
float dx = (velocityX * factor) * values[Matrix.MSCALE_X];
float dy = (velocityY * factor) * values[Matrix.MSCALE_Y];
PropertyValuesHolder flingX = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_X, values[Matrix.MTRANS_X], values[Matrix.MTRANS_X] + dx);
PropertyValuesHolder flingY = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_Y, values[Matrix.MTRANS_Y], values[Matrix.MTRANS_Y] + dy);
valueAnimator = ValueAnimator.ofPropertyValuesHolder(flingX, flingY);
valueAnimator.setDuration(flingDuration);
valueAnimator.addUpdateListener(new FlingAnimatorHandler(corrector));
valueAnimator.setInterpolator(new DecelerateInterpolator());
valueAnimator.start();
return true;
}
}
return super.onFling(e1, e2, velocityX, velocityY);
}
示例10: correctAbsolute
@Override
public float correctAbsolute(int vector, float x) {
switch(vector) {
case Matrix.MTRANS_X:
return correctTranslation(x, getImageView().getWidth(), getScaledImageWidth());
case Matrix.MTRANS_Y:
return correctTranslation(x, getImageView().getHeight(), getScaledImageHeight());
case Matrix.MSCALE_X:
case Matrix.MSCALE_Y:
float innerFitScale = getInnerFitScale();
float maxScale = maxScaleRelative ? innerFitScale * this.maxScale : this.maxScale;
return Math.max(Math.min(x, maxScale), innerFitScale);
default:
throw new IllegalArgumentException("Vector not supported");
}
}
示例11: limitTransAndScale
/**
* 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);
}
示例12: getCenterRectWidthHeight
/**
* 一个矩形(from), 在另一个矩形(to),居中显示时的宽高度
*/
public static int[] getCenterRectWidthHeight(RectF from, RectF to) {
int[] result = new int[2];
Matrix matrix = new Matrix();
matrix.setRectToRect(from, to, Matrix.ScaleToFit.CENTER);
float[] matrixValues = new float[9];
matrix.getValues(matrixValues);
result[0] = (int) (matrixValues[Matrix.MSCALE_X] * from.width());//缩放之后的宽度
result[1] = (int) (matrixValues[Matrix.MSCALE_Y] * from.height());//缩放之后的高度
return result;
}
示例13: checkDyBound
/**
* 和当前矩阵对比,检验dy,使图像移动后不会超出ImageView边界
* @param values
* @param dy
* @return
*/
private float checkDyBound(float[] values, float dy) {
float height=getHeight();
if(mImageHeight*values[Matrix.MSCALE_Y]<height)
return 0;
if(values[Matrix.MTRANS_Y]+dy>0)
dy=-values[Matrix.MTRANS_Y];
else if(values[Matrix.MTRANS_Y]+dy<-(mImageHeight*values[Matrix.MSCALE_Y]-height))
dy=-(mImageHeight*values[Matrix.MSCALE_Y]-height)-values[Matrix.MTRANS_Y];
return dy;
}
示例14: getDisplayedImageLocation
/**
* Returns the bitmap position inside an imageView.
*
* @param imageView source ImageView
*
* @return 0: left, 1: top, 2: width, 3: height
*/
public static int[] getDisplayedImageLocation(ImageView imageView) {
int[] ret = new int[4];
if (imageView == null || imageView.getDrawable() == null)
return ret;
// Get image dimensions
// Get image matrix values and place them in an array
float[] f = new float[9];
imageView.getImageMatrix().getValues(f);
// Extract the scale values using the constants (if aspect ratio maintained, scaleX == scaleY)
final float scaleX = f[Matrix.MSCALE_X];
final float scaleY = f[Matrix.MSCALE_Y];
// Get the drawable (could also get the bitmap behind the drawable and getWidth/getHeight)
final Drawable d = imageView.getDrawable();
final int origW = d.getIntrinsicWidth();
final int origH = d.getIntrinsicHeight();
// Calculate the actual dimensions
final int actW = Math.round(origW * scaleX);
final int actH = Math.round(origH * scaleY);
ret[2] = actW;
ret[3] = actH;
// Get image position
// We assume that the image is centered into ImageView
int imgViewW = imageView.getWidth();
int imgViewH = imageView.getHeight();
int[] imgViewScreenLoc = new int[2];
imageView.getLocationOnScreen(imgViewScreenLoc);
// get the actual image location inside its image view
int left = imgViewScreenLoc[0] + (imgViewW - actW) / 2;
int top = imgViewScreenLoc[1] + (imgViewH - actH) / 2;
ret[0] = left;
ret[1] = top;
return ret;
}
示例15: LoadGraphicsMatrix
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;
}