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

This code example shows how to use the following methods:getValues, postScale, set, setScale
			// 若为ZOOM模式,则多点触摸缩放 
			else if (mode == ZOOM) {
				float newDist = spacing(event);
				//Log.d(TAG, "newDist=" + newDist); 
				if (newDist > 10f) {
					matrix.set(savedMatrix);
					float scale = newDist / oldDist;
					// 设置缩放比例和图片中点位置 
					matrix.postScale(scale, scale, mid.x, mid.y);
				} 
			} 
			break; 
		} 
 
		// Perform the transformation 
		imgView.setImageMatrix(matrix);
		CheckView(); 
		return true; // indicate event was handled 
	} 
 

8
CodeRank
This code example shows how to use the following methods:mapRect, postTranslate, set, setRectToRect, setScale
            mShaderMatrix.setScale(scale, scale);
            mShaderMatrix.postTranslate((int) (dx + 0.5f), (int) (dy + 0.5f));
			break; 
		case CENTER_INSIDE:
			Log.d(TAG, "CENTER_INSIDE");
			mShaderMatrix.set(null);
             
            if (mBitmapWidth <= mBounds.width() && mBitmapHeight <= mBounds.height()) {
                scale = 1.0f;
            } else { 
                scale = Math.min((float) mBounds.width() / (float) mBitmapWidth,
                        (float) mBounds.height() / (float) mBitmapHeight);
            } 
             
            dx = (int) ((mBounds.width() - mBitmapWidth * scale) * 0.5f + 0.5f);
            dy = (int) ((mBounds.height() - mBitmapHeight * scale) * 0.5f + 0.5f);
 
            mShaderMatrix.setScale(scale, scale);
            mShaderMatrix.postTranslate(dx, dy);
             

7
CodeRank
This code example shows how to use the following methods:postTranslate, set
 
        if(child == mTitleBar) {
            mTitleBar.offsetLeftAndRight(getScrollX() - mTitleBar.getLeft());
 
            if(Build.VERSION.SDK_INT < 16) {
                mMatrix.set(canvas.getMatrix());
                mMatrix.postTranslate(0, -getScrollY());
                canvas.setMatrix(mMatrix);
            } 
        } 
 
        boolean result = super.drawChild(canvas, child, drawingTime);
        canvas.restore();
 
        return result;
    } 
 
    /** 
     * Gets the currently visible height of the title bar view if set. 
     * 
7
CodeRank
This code example shows how to use the following methods:mapRect, postConcat, set
 
        Matrix m = getImageViewMatrix();
 
        RectF rect = new RectF(0, 0, mBitmapDisplayed.getBitmap().getWidth(), mBitmapDisplayed.getBitmap().getHeight());
 
        m.mapRect(rect);
 
        float height = rect.height();
        float width = rect.width();
 
        float deltaX = 0, deltaY = 0;
 
        if (vertical) {
            int viewHeight = getHeight();
            if (height < viewHeight) {
                deltaY = (viewHeight - height) / 2 - rect.top;
            } else if (rect.top > 0) {
                deltaY = -rect.top;
            } else if (rect.bottom < viewHeight) {
                deltaY = getHeight() - rect.bottom;

7
CodeRank
This code example shows how to use the following methods:getValues, postScale, postTranslate, set, setScale
    	ImageView view = (ImageView) v;
    	if (started == false)
    		{initImage(view);
    		started = true;
    		} 
    	mootrix.getValues(matrixArray);
 
 
    	 
    	switch(event.getAction() & MotionEvent.ACTION_MASK)
    	{ 
    	case MotionEvent.ACTION_DOWN:
    		savedMootrix.set(mootrix);
    		stoort.set(event.getX(), event.getY());
    		moved = false;
    		MODE = DRAG;
    		Log.d(TAG, "MODE=DRAG");
    		break; 
    	case MotionEvent.ACTION_POINTER_UP:
    		MODE = DRAG;

6
CodeRank
This code example shows how to use the following methods:mapPoints, postConcat, set
        return true; 
    } 
 
    // Translate a given point through a given matrix. 
    static private void translatePoint(Matrix matrix, float [] xy) {
        matrix.mapPoints(xy);
    } 
 
    // Return the mapped x coordinate through the matrix. 
    static int mapXPoint(Matrix matrix, int point) {
        // Matrix's mapPoints takes an array of x/y coordinates. 
        // That's why we have to allocte an array of length two 
        // even though we don't use the y coordinate. 
        float [] xy = new float[2];
        xy[0] = point;
        xy[1] = 0F;
        matrix.mapPoints(xy);
        return (int) xy[0];
    } 
     

6
CodeRank
This code example shows how to use the following methods:mapRect, postConcat, set
 
        Matrix m = getImageViewMatrix();
 
        RectF rect = new RectF(0, 0, mBitmapDisplayed.getBitmap().getWidth(), mBitmapDisplayed.getBitmap().getHeight());
 
        m.mapRect(rect);
 
        float height = rect.height();
        float width = rect.width();
 
        float deltaX = 0, deltaY = 0;
 
        if (vertical) {
            int viewHeight = getHeight();
            if (height < viewHeight) {
                deltaY = (viewHeight - height) / 2 - rect.top;
            } else if (rect.top > 0) {
                deltaY = -rect.top;
            } else if (rect.bottom < viewHeight) {
                deltaY = getHeight() - rect.bottom;

6
CodeRank
This code example shows how to use the following methods:mapRect, postConcat, set
        Matrix m = getImageViewMatrix();
 
        RectF rect = new RectF(0, 0, mBitmapDisplayed.getBitmap().getWidth(),
                mBitmapDisplayed.getBitmap().getHeight());
 
        m.mapRect(rect);
 
        float height = rect.height();
        float width = rect.width();
 
        float deltaX = 0, deltaY = 0;
 
        if (vertical) {
            int viewHeight = getHeight();
            if (height < viewHeight) {
                deltaY = (viewHeight - height) / 2 - rect.top;
            } else if (rect.top > 0) {
                deltaY = -rect.top;
            } else if (rect.bottom < viewHeight) {
                deltaY = getHeight() - rect.bottom;

6
CodeRank
This code example shows how to use the following methods:mapRect, postTranslate, set, setRectToRect, setScale
            mShaderMatrix.setScale(scale, scale);
            mShaderMatrix.postTranslate((int) (dx + 0.5f), (int) (dy + 0.5f));
			break; 
		case CENTER_INSIDE:
			Log.d(TAG, "CENTER_INSIDE");
			mShaderMatrix.set(null);
             
            if (mBitmapWidth <= mBounds.width() && mBitmapHeight <= mBounds.height()) {
                scale = 1.0f;
            } else { 
                scale = Math.min((float) mBounds.width() / (float) mBitmapWidth,
                        (float) mBounds.height() / (float) mBitmapHeight);
            } 
             
            dx = (int) ((mBounds.width() - mBitmapWidth * scale) * 0.5f + 0.5f);
            dy = (int) ((mBounds.height() - mBitmapHeight * scale) * 0.5f + 0.5f);
 
            mShaderMatrix.setScale(scale, scale);
            mShaderMatrix.postTranslate(dx, dy);
             

6
CodeRank
This code example shows how to use the following methods:getValues, set, setScale, setValues
	} 
 
	public void zoomImageToWindow() { 
		if (bm.getWidth() < width && bm.getHeight() < height) {
			// matrix.reset(); 
			matrix.setScale(1f, 1f);
			bx = bm.getWidth();
			by = bm.getHeight();
		} else { 
			float scale = Math.min((float) width / (float) bm.getWidth(),
					(float) height / (float) bm.getHeight());
			FLog.d("scale=" + scale);
			matrix.setScale(scale, scale);
			bx = bm.getWidth() * scale;
			by = bm.getHeight() * scale;
		} 
 
		// 画像をView中央にセット 
		float[] values = new float[9];
		matrix.getValues(values);

6
CodeRank

Related Matrix set Questions & Answers:

set Method Overview
(deep) copy the src matrix into this matrix.
See Code Examples for other Android Matrix Methods: