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


Java Matrix.MSCALE_X属性代码示例

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


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

示例1: updateImageViewMatrix

/**
 *
 * @param imageView
 * @param width
 * @param height
 */
public static final void updateImageViewMatrix(ImageView imageView, float width, float height) {
    Drawable drawable = imageView.getDrawable();
    if(drawable == null) {
        throw new NullPointerException("ImageView drawable is null");
    }
    Matrix matrix = imageView.getImageMatrix();
    if(!matrix.isIdentity()) {
        float[] values = new float[9];
        matrix.getValues(values);

        RectF src = new RectF();
        src.left = 0;
        src.top = 0;
        src.right = width;
        src.bottom = height;

        RectF dst = new RectF();
        dst.left = values[Matrix.MTRANS_X];
        dst.top = values[Matrix.MTRANS_Y];
        dst.right = dst.left + (drawable.getIntrinsicWidth() * values[Matrix.MSCALE_X]);
        dst.bottom = dst.top + (drawable.getIntrinsicHeight() * values[Matrix.MSCALE_Y]);

        matrix.setRectToRect(src, dst, Matrix.ScaleToFit.CENTER);
    }
}
 
开发者ID:martinwithaar,项目名称:PinchToZoom,代码行数:31,代码来源:ImageViewUtils.java

示例2: canScroll

@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,代码行数:23,代码来源:ImageViewPager.java

示例3: translateMatrixAfterRotate

/**
 * After rotating, the matrix needs to be translated. This function finds the area of image
 * which was previously centered and adjusts translations so that is again the center, post-rotation.
 *
 * @param axis          Matrix.MTRANS_X or Matrix.MTRANS_Y
 * @param trans         the value of trans in that axis before the rotation
 * @param prevImageSize the width/height of the image before the rotation
 * @param imageSize     width/height of the image after rotation
 * @param prevViewSize  width/height of view before rotation
 * @param viewSize      width/height of view after rotation
 * @param drawableSize  width/height of drawable
 */
private void translateMatrixAfterRotate(int axis, float trans, float prevImageSize, float imageSize, int prevViewSize, int viewSize, int drawableSize) {
    if (imageSize < viewSize) {
        //
        // The width/height of image is less than the view's width/height. Center it.
        //
        m[axis] = (viewSize - (drawableSize * m[Matrix.MSCALE_X])) * 0.5f;

    } else if (trans > 0) {
        //
        // The image is larger than the view, but was not before rotation. Center it.
        //
        m[axis] = -((imageSize - viewSize) * 0.5f);

    } else {
        //
        // Find the area of the image which was previously centered in the view. Determine its distance
        // from the left/top side of the view as a fraction of the entire image's width/height. Use that percentage
        // to calculate the trans in the new view width/height.
        //
        float percentage = (Math.abs(trans) + (0.5f * prevViewSize)) / prevImageSize;
        m[axis] = -((percentage * imageSize) - (viewSize * 0.5f));
    }
}
 
开发者ID:rozdoum,项目名称:social-app-android,代码行数:35,代码来源:TouchImageView.java

示例4: translateMatrixAfterRotate

/**
 * After rotating, the matrix needs to be translated. This function finds the area of image 
 * which was previously centered and adjusts translations so that is again the center, post-rotation.
 * 
 * @param axis Matrix.MTRANS_X or Matrix.MTRANS_Y
 * @param trans the value of trans in that axis before the rotation
 * @param prevImageSize the width/height of the image before the rotation
 * @param imageSize width/height of the image after rotation
 * @param prevViewSize width/height of view before rotation
 * @param viewSize width/height of view after rotation
 * @param drawableSize width/height of drawable
 */
private void translateMatrixAfterRotate(int axis, float trans, float prevImageSize, float imageSize, int prevViewSize, int viewSize, int drawableSize) {
	if (imageSize < viewSize) {
    	//
    	// The width/height of image is less than the view's width/height. Center it.
    	//
    	m[axis] = (viewSize - (drawableSize * m[Matrix.MSCALE_X])) * 0.5f;
    	
    } else if (trans > 0) {
    	//
    	// The image is larger than the view, but was not before rotation. Center it.
    	//
    	m[axis] = -((imageSize - viewSize) * 0.5f);
    	
    } else {
    	//
    	// Find the area of the image which was previously centered in the view. Determine its distance
    	// from the left/top side of the view as a fraction of the entire image's width/height. Use that percentage
    	// to calculate the trans in the new view width/height.
    	//
    	float percentage = (Math.abs(trans) + (0.5f * prevViewSize)) / prevImageSize;
    	m[axis] = -((percentage * imageSize) - (viewSize * 0.5f));
    }
}
 
开发者ID:customerly,项目名称:Customerly-Android-SDK,代码行数:35,代码来源:TouchImageView.java

示例5: translateMatrixAfterRotate

/**
 * After rotating, the matrix needs to be translated. This function finds the area of image
 * which was previously centered and adjusts translations so that is again the center, post-rotation.
 *
 * @param axis Matrix.MTRANS_X or Matrix.MTRANS_Y
 * @param trans the value of trans in that axis before the rotation
 * @param prevImageSize the width/height of the image before the rotation
 * @param imageSize width/height of the image after rotation
 * @param prevViewSize width/height of view before rotation
 * @param viewSize width/height of view after rotation
 * @param drawableSize width/height of drawable
 */
private void translateMatrixAfterRotate(int axis, float trans, float prevImageSize, float imageSize, int prevViewSize, int viewSize, int drawableSize) {
    if (imageSize < viewSize) {
        //
        // The width/height of image is less than the view's width/height. Center it.
        //
        m[axis] = (viewSize - (drawableSize * m[Matrix.MSCALE_X])) * 0.5f;

    } else if (trans > 0) {
        //
        // The image is larger than the view, but was not before rotation. Center it.
        //
        m[axis] = -((imageSize - viewSize) * 0.5f);

    } else {
        //
        // Find the area of the image which was previously centered in the view. Determine its distance
        // from the left/top side of the view as a fraction of the entire image's width/height. Use that percentage
        // to calculate the trans in the new view width/height.
        //
        float percentage = (Math.abs(trans) + (0.5f * prevViewSize)) / prevImageSize;
        m[axis] = -((percentage * imageSize) - (viewSize * 0.5f));
    }
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:35,代码来源:TouchImageView.java

示例6: calcTextSizeForRect

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,代码行数:17,代码来源:CircleProgressView.java

示例7: postTranslate

@Override
public void postTranslate(float deltaX, float deltaY) {
    super.postTranslate(deltaX, deltaY);

    Iterator<MyHighlightView> iterator = mOverlayViews.iterator();
    while (iterator.hasNext()) {
        MyHighlightView view = iterator.next();
        if (getScale() != 1) {
            float[] mvalues = new float[9];
            getImageMatrix().getValues(mvalues);
            final float scale = mvalues[Matrix.MSCALE_X];

            if (!mScaleWithContent)
                view.getCropRectF().offset(-deltaX / scale, -deltaY / scale);
        }

        view.getMatrix().set(getImageMatrix());
        view.invalidate();
    }
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:20,代码来源:MyImageViewDrawableOverlay.java

示例8: 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();
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:17,代码来源:PaintFragment.java

示例9: translateMatrixAfterRotate

/**
 * After rotating, the matrix needs to be translated. This function finds the area of image
 * which was previously centered and adjusts translations so that is again the center,
 * post-rotation.
 *
 * @param axis Matrix.MTRANS_X or Matrix.MTRANS_Y
 * @param trans the value of trans in that axis before the rotation
 * @param prevImageSize the width/height of the image before the rotation
 * @param imageSize width/height of the image after rotation
 * @param prevViewSize width/height of view before rotation
 * @param viewSize width/height of view after rotation
 * @param drawableSize width/height of drawable
 */
private void translateMatrixAfterRotate(int axis, float trans, float prevImageSize,
    float imageSize, int prevViewSize, int viewSize, int drawableSize) {
  if (imageSize < viewSize) {
    //
    // The width/height of image is less than the view's width/height. Center it.
    //
    m[axis] = (viewSize - (drawableSize * m[Matrix.MSCALE_X])) * 0.5f;
  } else if (trans > 0) {
    //
    // The image is larger than the view, but was not before rotation. Center it.
    //
    m[axis] = -((imageSize - viewSize) * 0.5f);
  } else {
    //
    // Find the area of the image which was previously centered in the view. Determine its distance
    // from the left/top side of the view as a fraction of the entire image's width/height. Use that percentage
    // to calculate the trans in the new view width/height.
    //
    float percentage = (Math.abs(trans) + (0.5f * prevViewSize)) / prevImageSize;
    m[axis] = -((percentage * imageSize) - (viewSize * 0.5f));
  }
}
 
开发者ID:malijie,项目名称:PhotoPicker-master,代码行数:35,代码来源:TouchImageView.java

示例10: correctRelative

/**
 * <p>Returns the corrected value of the given relative vector.</p>
 * @param vector
 * @param x
    * @return
    */
public float correctRelative(int vector, float x) {
	float v = getValues()[vector];
	switch(vector) {
		case Matrix.MTRANS_X:
		case Matrix.MTRANS_Y:
			return correctAbsolute(vector, v + x) - v;
		case Matrix.MSCALE_X:
		case Matrix.MSCALE_Y:
			return correctAbsolute(vector, v * x) / v;
		default:
			throw new IllegalArgumentException("Vector not supported");
	}
}
 
开发者ID:martinwithaar,项目名称:PinchToZoom,代码行数:19,代码来源:MatrixCorrector.java

示例11: 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;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:16,代码来源:RUtils.java

示例12: checkDxBound

/**
 *  和当前矩阵对比,检验dx,使图像移动后不会超出ImageView边界
 *  @param values
 *  @param dx
 *  @return
 */
private float checkDxBound(float[] values,float dx,float dy) {
    float width=getWidth();
    if(!mLeftDragable&&dx<0){
        //加入和y轴的对比,表示在监听到垂直方向的手势时不切换Item
        if(Math.abs(dx)*0.4f>Math.abs(dy)&&mFirstMove){
            stopDrag();
        }
        return 0;
    }
    if(!mRightDragable&&dx>0){
        //加入和y轴的对比,表示在监听到垂直方向的手势时不切换Item
        if(Math.abs(dx)*0.4f>Math.abs(dy)&&mFirstMove){
            stopDrag();
        }
        return 0;
    }
    mLeftDragable=true;
    mRightDragable=true;
    if(mFirstMove) mFirstMove=false;
    if(mImageWidth*values[Matrix.MSCALE_X]<width){
        return 0;

    }
    if(values[Matrix.MTRANS_X]+dx>0){
        dx=-values[Matrix.MTRANS_X];
    }
    else if(values[Matrix.MTRANS_X]+dx<-(mImageWidth*values[Matrix.MSCALE_X]-width)){
        dx=-(mImageWidth*values[Matrix.MSCALE_X]-width)-values[Matrix.MTRANS_X];
    }
    return dx;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:37,代码来源:MatrixImageView.java

示例13: 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;
}
 
开发者ID:JustKiddingBaby,项目名称:FragmentRigger,代码行数:51,代码来源:ImageViewUtil.java

示例14: checkMaxScale

/**
 *  检验scale,使图像缩放后不会超出最大倍数
 *  @param scale
 *  @param values
 *  @return
 */
private float checkMaxScale(float scale, float[] values) {
    if(scale*values[Matrix.MSCALE_X]>mMaxScale*mScale){
        scale=mMaxScale*mScale/values[Matrix.MSCALE_X];
    }
    else if(scale*values[Matrix.MSCALE_X]<=mScale){
        scale=1;
    }

    return scale;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:16,代码来源:MatrixImageView.java

示例15: getScale

private float getScale() {
    float[] values = new float[9];
    mImageMatrix.getValues(values);
    return values[Matrix.MSCALE_X];
}
 
开发者ID:Sora-Shiro,项目名称:ChinaMapInfoView,代码行数:5,代码来源:ChinaMapInfoView.java


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