Matrix preRotate - 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 preRotate method.

This code example shows how to use the following methods:postTranslate, preRotate, setTranslate
        final int length = isHoriz() ? w : h;
        mRightHandleX = length - edgePadding - mDimpleWidth / 2;
        mDimpleSpacing = (length / 2) - mLeftHandleX;
 
        // bg matrix only needs to be calculated once 
        mBgMatrix.setTranslate(0, 0);
        if (!isHoriz()) { 
            // set up matrix for translating drawing of background and arrow assets 
            final int left = w - mBackgroundHeight;
            mBgMatrix.preRotate(-90, 0, 0);
            mBgMatrix.postTranslate(left, h);
 
        } else { 
            mBgMatrix.postTranslate(0, h - mBackgroundHeight);
        } 
    } 
 
    private boolean isHoriz() { 
        return mOrientation == HORIZONTAL;
    } 
8
CodeRank
This code example shows how to use the following methods:mapPoints, preRotate, preScale, preTranslate
 
		this.testTransformationVsMatrix(points);
	} 
 
	public void testPreComplex() { 
		this.mMatrix.preTranslate(10, 2);
		this.mTransformation.preTranslate(10, 2);
 
		this.mMatrix.preScale(3, 2);
		this.mTransformation.preScale(3, 2);
 
		this.mMatrix.preRotate(3);
		this.mTransformation.preRotate(3);
 
		this.mMatrix.preScale(2, 2);
		this.mTransformation.preScale(2, 2);
 
		this.mMatrix.preTranslate(-10, 10);
		this.mTransformation.preTranslate(-10, 10);
 

7
CodeRank
This code example shows how to use the following methods:createBitmap, preRotate
				// Getting width & height of the given image. 
				int w = bitmap.getWidth();
				int h = bitmap.getHeight();
 
				// Setting pre rotate 
				Matrix mtx = new Matrix();
				mtx.preRotate(rotate);
 
				// Rotating Bitmap 
				bitmap = Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, false);
			} 
 
			// Convert to ARGB_8888, required by tess 
			bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
 
		} catch (IOException e) {
			Log.e(TAG, "Couldn't correct orientation: " + e.toString());
		} 
 
		// _image.setImageBitmap( bitmap ); 
7
CodeRank
This code example shows how to use the following methods:postTranslate, preRotate, setTranslate
        final int length = isHoriz() ? w : h;
        mRightHandleX = length - edgePadding - mDimpleWidth / 2;
        mDimpleSpacing = (length / 2) - mLeftHandleX;
 
        // bg matrix only needs to be calculated once 
        mBgMatrix.setTranslate(0, 0);
        if (!isHoriz()) { 
            // set up matrix for translating drawing of background and arrow assets 
            final int left = w - mBackgroundHeight;
            mBgMatrix.preRotate(-90, 0, 0);
            mBgMatrix.postTranslate(left, h);
 
        } else { 
            mBgMatrix.postTranslate(0, h - mBackgroundHeight);
        } 
    } 
 
    private boolean isHoriz() { 
        return mOrientation == HORIZONTAL;
    } 
7
CodeRank
This code example shows how to use the following methods:preRotate, preScale, preTranslate, setTranslate
        final float angle = (float) Math.toDegrees(theta) + 90.0f;
 
        // compose matrix 
        float sx = Math.min(mSquareWidth / mBitmapWidth, 1.0f);
        float sy = Math.min(mSquareHeight / mBitmapHeight, 1.0f);
        mArrowMatrix.setTranslate(leftX + offsetX, topY + offsetY); // transform to cell position
        mArrowMatrix.preTranslate(mBitmapWidth/2, mBitmapHeight/2);
        mArrowMatrix.preScale(sx, sy);
        mArrowMatrix.preTranslate(-mBitmapWidth/2, -mBitmapHeight/2);
        mArrowMatrix.preRotate(angle, cellWidth / 2.0f, cellHeight / 2.0f);  // rotate about cell center
        mArrowMatrix.preTranslate((cellWidth - arrow.getWidth()) / 2.0f, 0.0f); // translate to 12:00 pos
        canvas.drawBitmap(arrow, mArrowMatrix, mPaint);
    } 
 
    /** 
     * @param canvas 
     * @param leftX 
     * @param topY 
     * @param partOfPattern Whether this circle is part of the pattern. 
     */ 
6
CodeRank
This code example shows how to use the following methods:postTranslate, preRotate, preScale, preTranslate
This code example shows how to use the following methods:preRotate, preScale, preTranslate
	} 
	public void Draw(Canvas canvas)
	{ 
		if(bitmap==null || canvas==null)
			return; 
		 Matrix transform = new Matrix();
		    //transform.setTranslate(x+bitmap.getWidth()/2, y+bitmap.getHeight()/2); 
		    transform.preScale(scale,scale);
		    transform.preTranslate(x, y);
		    transform.preRotate(Angle,bitmap.getWidth()/2, bitmap.getHeight()/2);
		  
		    Paint paint = new Paint();
		    paint.setAlpha(255);
 
		  canvas.drawBitmap(bitmap,transform, paint);
 
	} 
	} 
	 
 
6
CodeRank
This code example shows how to use the following methods:createBitmap, preRotate
				options.inPreferredConfig = Bitmap.Config.RGB_565;
	        mBitmap = BitmapFactory.decodeFile(mPath, options);
        } 
         
        // Rotate to right direction 
        Matrix matrix = new Matrix();
		float rotation = rotationForImage(mPath);
		if (rotation != 0f) {
			matrix.preRotate(rotation);
		} 
 
		if(mBitmap != null) {
			int height = mBitmap.getHeight();
			int width = mBitmap.getWidth();
			mBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, matrix,
					true); 
		} 
	    return mBitmap;
	} 
	 
6
CodeRank
This code example shows how to use the following methods:postScale, postTranslate, preRotate, reset
		paint.setTypeface(Typeface.MONOSPACE);
		paint.setFakeBoldText(true);
		paint.setColor(0xFF2040A0);
		paint.setTextSize(32);
		setTextureText("world ", paint, mTextureIds[0], mMatrixBackground);
		mMatrixBackground.postScale(8, 8f * height / width);
		mMatrixBackground.preRotate(-35);
 
		// Generate foreground texture. 
		paint.setColor(0xFFA05030);
		paint.setTextSize(128);
		setTextureText("hello", paint, mTextureIds[1], mMatrixForeground);
		mMatrixForeground.postScale(1f, (float) height / width);
	} 
 
	@Override 
	public void onSurfaceCreated(GL10 unused, EGLConfig config) {
		// Check if shader compiler is supported. 
		GLES20.glGetBooleanv(GLES20.GL_SHADER_COMPILER, mShaderCompilerSupport,
				0); 

6
CodeRank
This code example shows how to use the following methods:createBitmap, preRotate, setTranslate
	 
	public static Bitmap getRotated(Bitmap bm, float deg) {
		int width = bm.getWidth();
		int height = bm.getHeight();
		 
		Matrix matrix = new Matrix();
		 
		matrix.setTranslate(width / 2, height / 2);
		matrix.preRotate(deg, width / 2, height / 2);
		 
		return Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
	} 
	 
	 
} 
6
CodeRank

Related Matrix preRotate Questions & Answers:

preRotate Method Overview
Preconcats the matrix with the specified rotation.
See Code Examples for other Android Matrix Methods: