Matrix postTranslate - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Matrix postTranslate method.

This code example shows how to use the following methods:mapRect, postScale, postTranslate, preTranslate, reset
 
        // use a rectangle at 0,0 to make sure we don't run into issues with scaling 
        r.set(0, 0, w, h);
 
        final Matrix m = mTempMatrix;
        m.reset();
        transformMatrix(m, view);
        mTempMatrix.mapRect(r);
 
        r.offset(view.getLeft(), view.getTop());
 
        // Straighten coords if rotations flipped them 
        if (r.right < r.left) {
            final float f = r.right;
            r.right = r.left;
            r.left = f;
        } 
        if (r.bottom < r.top) {
            final float f = r.top;
            r.top = r.bottom;

8
CodeRank
This code example shows how to use the following methods:postTranslate, setScale
This code example shows how to use the following methods:mapRect, postTranslate, setRotate
This code example shows how to use the following methods:mapRect, postScale, postTranslate, reset
 
        // use a rectangle at 0,0 to make sure we don't run into issues with scaling 
        r.set(0, 0, w, h);
 
        final Matrix m = mTempMatrix;
        m.reset();
        transformMatrix(m, view);
        mTempMatrix.mapRect(r);
 
        r.offset(view.getLeft(), view.getTop());
 
        // Straighten coords if rotations flipped them 
        if (r.right < r.left) {
            final float f = r.right;
            r.right = r.left;
            r.left = f;
        } 
        if (r.bottom < r.top) {
            final float f = r.top;
            r.top = r.bottom;

8
CodeRank
This code example shows how to use the following methods:getValues, postTranslate
	} 
	 
	private boolean checkImageScrollBeyondBorders(float dx, float dy)
	{ 
		float[] matrixValues = new float[9];
		Matrix m = new Matrix(changeMatrix);
		// Apply the translation 
		m.postTranslate(-dx, -dy);
		m.getValues(matrixValues);
		// Image can move only the extra width or height that is available 
		// after scaling from the original width or height 
		float scaledAdditionalHeight = imageView.getHeight() * (matrixValues[4] - 1);
		float scaledAdditionalWidth = imageView.getWidth() * (matrixValues[0] - 1);
		if (matrixValues[5] > -scaledAdditionalHeight && matrixValues[5] < 0 && matrixValues[2] > -scaledAdditionalWidth
			&& matrixValues[2] < 0) {
			return false; 
		} 
		return true; 
	} 
} 
8
CodeRank
This code example shows how to use the following methods:getValues, postTranslate, set, setScale
    /** 
     * 限制最大最小缩放比例,自动居中 
     */ 
    private void CheckView() { 
        float p[] = new float[9];
        matrix.getValues(p);
        if (mode == ZOOM) {
            if (p[0] < minScaleR) {
                matrix.setScale(minScaleR, minScaleR);
            } 
            if (p[0] > MAX_SCALE) {
                matrix.set(savedMatrix);
            } 
        } 
        center(); 
    } 
 
    /** 
     * 最小缩放比例,最大为100% 
     */ 

8
CodeRank
This code example shows how to use the following methods:mapRect, postRotate, postScale, postTranslate, reset
     * @see android.widget.ImageView#setImageBitmap(android.graphics.Bitmap) 
     */ 
    @Override 
    public void setImageBitmap(Bitmap bitmap)
    { 
        Matrix matrix = new Matrix();
        matrix.reset();
        // apply the camera display characteristics. First mirror the image... 
        if (mbMirror)
        { 
            matrix.postScale(-1f, 1f);
        } 
        // then rotate it... 
        matrix.postRotate(mnDisplayOrientation);
        /** 
         * Math is hard!  
         *         -- Barbie 
         *  
         * We could calculate the matrix that will map the rotated and possibly 
         * mirrored image to the display, but it is much easier to compose a 

8
CodeRank
This code example shows how to use the following methods:postRotate, postTranslate, preTranslate
		mBitmap = bitmap;
	} 
 
	public Matrix getRotateMatrix() {
		// By default this is an identity matrix. 
		Matrix matrix = new Matrix();
		if (mRotation != 0) {
			// We want to do the rotation at origin, but since the bounding 
			// rectangle will be changed after rotation, so the delta values 
			// are based on old & new width/height respectively. 
			int cx = mBitmap.getWidth() / 2;
			int cy = mBitmap.getHeight() / 2;
			matrix.preTranslate(-cx, -cy);
			matrix.postRotate(mRotation);
			matrix.postTranslate(getWidth() / 2, getHeight() / 2);
		} 
		return matrix;
	} 
 
	public boolean isOrientationChanged() { 
8
CodeRank
This code example shows how to use the following methods:postRotate, postScale, postTranslate, preTranslate
			if (bitmap != null) {
				float bitmapWidth = bitmap.getWidth();
				float bitmapHeight = bitmap.getHeight();
				float scale = 1.0f;
 
				Matrix matrix = new Matrix();
				if (width != bitmapWidth || height != bitmapHeight) {
					if (width == bitmapHeight || height == bitmapWidth) {
						if (width > height) {
							matrix.postRotate(-90, width / 2, height / 2);
						} else if (bitmapWidth != bitmapHeight) {
							matrix.postRotate(90, width / 2, height / 2);
						} else { 
							if (painter.getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
								matrix.postRotate(-90, width / 2, height / 2);
							} 
						} 
					} else { 
						if (painter.getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
							if (bitmapWidth > bitmapHeight

8
CodeRank
This code example shows how to use the following methods:postTranslate, preTranslate

Related Matrix postTranslate Questions & Answers:

postTranslate Method Overview
Postconcats the matrix with the specified translation.
See Code Examples for other Android Matrix Methods: