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


Java Matrix.postRotate方法代码示例

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


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

示例1: onLoadingDrawableSet

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void onLoadingDrawableSet(Drawable imageDrawable) {
	if (null != imageDrawable) {
		final int dHeight = imageDrawable.getIntrinsicHeight();
		final int dWidth = imageDrawable.getIntrinsicWidth();

		/**
		 * We need to set the width/height of the ImageView so that it is
		 * square with each side the size of the largest drawable dimension.
		 * This is so that it doesn't clip when rotated.
		 */
		ViewGroup.LayoutParams lp = mHeaderImage.getLayoutParams();
		lp.width = lp.height = Math.max(dHeight, dWidth);
		mHeaderImage.requestLayout();

		/**
		 * We now rotate the Drawable so that is at the correct rotation,
		 * and is centered.
		 */
		mHeaderImage.setScaleType(ScaleType.MATRIX);
		Matrix matrix = new Matrix();
		matrix.postTranslate((lp.width - dWidth) / 2f, (lp.height - dHeight) / 2f);
		matrix.postRotate(getDrawableRotationAngle(), lp.width / 2f, lp.height / 2f);
		mHeaderImage.setImageMatrix(matrix);
	}
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:27,代码来源:FlipLoadingLayout.java

示例2: rotateBitmapByDegree

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 将图片按照某个角度进行旋转
 *
 * @param bm     需要旋转的图片
 * @param degree 旋转角度
 * @return 旋转后的图片
 */
private Bitmap rotateBitmapByDegree(Bitmap bm, int degree) {
    Bitmap returnBm = null;

    // 根据旋转角度,生成旋转矩阵
    Matrix matrix = new Matrix();
    matrix.postRotate(degree);
    try {
        // 将原始图片按照旋转矩阵进行旋转,并得到新的图片
        returnBm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
    } catch (OutOfMemoryError e) {
    }
    if (returnBm == null) {
        returnBm = bm;
    }
    if (bm != returnBm) {
        bm.recycle();
    }
    return returnBm;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:ImageRotateUtil.java

示例3: rotateBitmapByDegree

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 将图片按照某个角度进行旋转
 *
 * @param bm     需要旋转的图片
 * @param degree 旋转角度
 * @return 旋转后的图片
 */
public static Bitmap rotateBitmapByDegree(Bitmap bm, int degree) {
    Bitmap returnBm = null;

    // 根据旋转角度,生成旋转矩阵
    Matrix matrix = new Matrix();
    matrix.postRotate(degree);
    try {
        // 将原始图片按照旋转矩阵进行旋转,并得到新的图片
        returnBm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
    } catch (OutOfMemoryError e) {
        e.printStackTrace();
    }
    if (returnBm == null) {
        returnBm = bm;
    }
    if (bm != returnBm) {
        bm.recycle();
    }
    return returnBm;
}
 
开发者ID:Wan7451,项目名称:mvparms,代码行数:28,代码来源:DrawableProvider.java

示例4: configureTransform

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 */
private void configureTransform(final int viewWidth, final int viewHeight) {
  final Activity activity = getActivity();
  if (null == textureView || null == previewSize || null == activity) {
    return;
  }
  final int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
  final Matrix matrix = new Matrix();
  final RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
  final RectF bufferRect = new RectF(0, 0, previewSize.getHeight(), previewSize.getWidth());
  final float centerX = viewRect.centerX();
  final float centerY = viewRect.centerY();
  if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
    bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
    matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
    final float scale = Math.max((float) viewHeight / previewSize.getHeight(),
        (float) viewWidth / previewSize.getWidth());
    matrix.postScale(scale, scale, centerX, centerY);
    matrix.postRotate(90 * (rotation - 2), centerX, centerY);
  } else if (Surface.ROTATION_180 == rotation) {
    matrix.postRotate(180, centerX, centerY);
  }
  textureView.setTransform(matrix);
}
 
开发者ID:flipper83,项目名称:SortingHatAndroid,代码行数:32,代码来源:CameraConnectionFragment.java

示例5: considerExactScaleAndOrientatiton

import android.graphics.Matrix; //导入方法依赖的package包/类
protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo
        decodingInfo, int rotation, boolean flipHorizontal) {
    Matrix m = new Matrix();
    ImageScaleType scaleType = decodingInfo.getImageScaleType();
    if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) {
        float scale = ImageSizeUtils.computeImageScale(new ImageSize(subsampledBitmap
                .getWidth(), subsampledBitmap.getHeight(), rotation), decodingInfo
                .getTargetSize(), decodingInfo.getViewScaleType(), scaleType ==
                ImageScaleType.EXACTLY_STRETCHED);
        if (Float.compare(scale, 1.0f) != 0) {
            m.setScale(scale, scale);
            if (this.loggingEnabled) {
                L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), Float.valueOf(scale),
                        decodingInfo.getImageKey());
            }
        }
    }
    if (flipHorizontal) {
        m.postScale(-1.0f, 1.0f);
        if (this.loggingEnabled) {
            L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey());
        }
    }
    if (rotation != 0) {
        m.postRotate((float) rotation);
        if (this.loggingEnabled) {
            L.d(LOG_ROTATE_IMAGE, Integer.valueOf(rotation), decodingInfo.getImageKey());
        }
    }
    Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap
            .getWidth(), subsampledBitmap.getHeight(), m, true);
    if (finalBitmap != subsampledBitmap) {
        subsampledBitmap.recycle();
    }
    return finalBitmap;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:37,代码来源:BaseImageDecoder.java

示例6: setupBarPaint

import android.graphics.Matrix; //导入方法依赖的package包/类
private void setupBarPaint() {
    if (mBarColors.length > 1) {
        mBarPaint.setShader(new SweepGradient(mCircleBounds.centerX(), mCircleBounds.centerY(), mBarColors, null));
        Matrix matrix = new Matrix();
        mBarPaint.getShader().getLocalMatrix(matrix);

        matrix.postTranslate(-mCircleBounds.centerX(), -mCircleBounds.centerY());
        matrix.postRotate(mStartAngle);
        matrix.postTranslate(mCircleBounds.centerX(), mCircleBounds.centerY());
        mBarPaint.getShader().setLocalMatrix(matrix);
        mBarPaint.setColor(mBarColors[0]);
    } else if (mBarColors.length == 1) {
        mBarPaint.setColor(mBarColors[0]);
        mBarPaint.setShader(null);
    } else {
        mBarPaint.setColor(mBarColorStandard);
        mBarPaint.setShader(null);
    }

    mBarPaint.setAntiAlias(true);
    mBarPaint.setStrokeCap(mBarStrokeCap);
    mBarPaint.setStyle(Style.STROKE);
    mBarPaint.setStrokeWidth(mBarWidth);

    if (mBarStrokeCap != Paint.Cap.BUTT) {
        mShaderlessBarPaint = new Paint(mBarPaint);
        mShaderlessBarPaint.setShader(null);
        mShaderlessBarPaint.setColor(mBarColors[0]);
    }
}
 
开发者ID:VRLoser,项目名称:greendao_expand,代码行数:31,代码来源:CircleProgressView.java

示例7: updateRotationDependant

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
protected void updateRotationDependant() {
    super.updateRotationDependant();

    Matrix rotationMatrix = new Matrix();
    rotationMatrix.postRotate(mRotation, mCenter.x, mCenter.y);

    for (Field field : mFields) {
        field.rawPath.transform(rotationMatrix, /* to */ field.cachedPath);
    }
}
 
开发者ID:eltos,项目名称:SimpleDialogFragments,代码行数:12,代码来源:ColorWheelView.java

示例8: applyPendingRotation

import android.graphics.Matrix; //导入方法依赖的package包/类
private void applyPendingRotation() {
    if(mRotation != 0) {
        //Normalize rotation
        mRotation = mRotation % 360;
        if (mRotation < 0) mRotation += 360;

        //Get the bitmap
        File imageFile = new File(FileUtil.getImageAttachmentDir(this), mImageAttachment.getImageFilename());
        Bitmap imageBitmap = ImageUtil.getBitmap(imageFile);

        //Rotate it
        Matrix matrix = new Matrix();
        matrix.postRotate(mRotation);
        imageBitmap = Bitmap.createBitmap(imageBitmap, 0, 0, imageBitmap.getWidth(), imageBitmap.getHeight(), matrix, true);

        try {
            ImageUtil.saveBitmapAsJpeg(imageFile, imageBitmap, IMAGE_COMPRESSION_PERCENTAGE);
        }catch (IOException e) {
            SnackbarUtil.showSnackbar(mContainer, SnackbarUtil.SnackbarType.ERROR, R.string.activity_edit_image_attachment_snackbar_error_could_not_rotate, SnackbarUtil.SnackbarDuration.LONG, null);
        }

        //Reload ImageView
        mImage.setImageBitmap(imageBitmap);
        mImage.setRotation(0);

        //Reset Rotation
        mRotation = 0;
    }
}
 
开发者ID:abicelis,项目名称:Remindy,代码行数:30,代码来源:EditImageAttachmentActivity.java

示例9: rotateImage

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * ��תͼƬ
 * 
 * @param angle	��ת�Ƕ�
 * @param bitmap ԭͼ
 * @return bitmap ��ת���ͼƬ
 */
public static Bitmap rotateImage(int angle, Bitmap bitmap) {
	// ͼƬ��ת����
	Matrix matrix = new Matrix();
	matrix.postRotate(angle);
	// �õ���ת���ͼƬ
	Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
			bitmap.getWidth(), bitmap.getHeight(), matrix, true);
	return resizedBitmap;
}
 
开发者ID:JosephPai,项目名称:WithYou,代码行数:17,代码来源:FaceUtil.java

示例10: prepareMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
public static void prepareMatrix(Matrix matrix, boolean mirror, int displayOrientation,
                                 int viewWidth, int viewHeight) {
  // Need mirror for front camera.
  matrix.setScale(mirror ? -1 : 1, 1);
  // This is the value for android.hardware.Camera.setDisplayOrientation.
  matrix.postRotate(displayOrientation);
  // Camera driver coordinates range from (-1000, -1000) to (1000, 1000).
  // UI coordinates range from (0, 0) to (width, height).
  matrix.postScale(viewWidth / 2000f, viewHeight / 2000f);
  matrix.postTranslate(viewWidth / 2f, viewHeight / 2f);
}
 
开发者ID:windwang,项目名称:react-native-face-detect,代码行数:12,代码来源:Converter.java

示例11: considerExactScaleAndOrientatiton

import android.graphics.Matrix; //导入方法依赖的package包/类
protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo decodingInfo,
		int rotation, boolean flipHorizontal) {
	Matrix m = new Matrix();
	// Scale to exact size if need
	ImageScaleType scaleType = decodingInfo.getImageScaleType();
	if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) {
		ImageSize srcSize = new ImageSize(subsampledBitmap.getWidth(), subsampledBitmap.getHeight(), rotation);
		float scale = ImageSizeUtils.computeImageScale(srcSize, decodingInfo.getTargetSize(), decodingInfo
				.getViewScaleType(), scaleType == ImageScaleType.EXACTLY_STRETCHED);
		if (Float.compare(scale, 1f) != 0) {
			m.setScale(scale, scale);

			if (loggingEnabled) {
				L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), scale, decodingInfo.getImageKey());
			}
		}
	}
	// Flip bitmap if need
	if (flipHorizontal) {
		m.postScale(-1, 1);

		if (loggingEnabled) L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey());
	}
	// Rotate bitmap if need
	if (rotation != 0) {
		m.postRotate(rotation);

		if (loggingEnabled) L.d(LOG_ROTATE_IMAGE, rotation, decodingInfo.getImageKey());
	}

	Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap.getWidth(), subsampledBitmap
			.getHeight(), m, true);
	if (finalBitmap != subsampledBitmap) {
		subsampledBitmap.recycle();
	}
	return finalBitmap;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:BaseImageDecoder.java

示例12: forceUpdate

import android.graphics.Matrix; //导入方法依赖的package包/类
public boolean forceUpdate() {
    Log.i(LOG_TAG, "forceUpdate");

    RectF cropRect = getCropRectF();
    RectF drawRect = getDrawRect();

    if (mEditableContent != null) {

        final float textWidth = mContent.getCurrentWidth();
        final float textHeight = mContent.getCurrentHeight();

        updateRatio();

        RectF textRect = new RectF(cropRect);
        getMatrix().mapRect(textRect);

        float dx = textWidth - textRect.width();
        float dy = textHeight - textRect.height();

        float[] fpoints = new float[] { dx, dy };

        Matrix rotateMatrix = new Matrix();
        rotateMatrix.postRotate(-mRotation);

        dx = fpoints[0];
        dy = fpoints[1];

        float xDelta = dx * (cropRect.width() / drawRect.width());
        float yDelta = dy * (cropRect.height() / drawRect.height());

        if (xDelta != 0 || yDelta != 0) {
            growBy(xDelta / 2, yDelta / 2, false);
        }

        invalidate();
        return true;
    }
    return false;
}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:40,代码来源:MyHighlightView.java

示例13: getRotateMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
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;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:16,代码来源:RotateBitmap.java

示例14: onMouseMove

import android.graphics.Matrix; //导入方法依赖的package包/类
public void onMouseMove(int edge, MotionEvent event2, float dx, float dy) {
    if (edge == NONE) {
        return;
    }

    fpoints[0] = dx;
    fpoints[1] = dy;

    float xDelta;
    float yDelta;

    if (edge == MOVE) {
        moveBy(dx * (mCropRect.width() / mDrawRect.width()),
            dy * (mCropRect.height() / mDrawRect.height()));
    } else if (edge == ROTATE) {
        dx = fpoints[0];
        dy = fpoints[1];
        xDelta = dx * (mCropRect.width() / mDrawRect.width());
        yDelta = dy * (mCropRect.height() / mDrawRect.height());
        rotateBy(event2.getX(), event2.getY(), dx, dy);

        invalidate();
        // mContext.invalidate( getInvalidationRect() );
    } else {

        Matrix rotateMatrix = new Matrix();
        rotateMatrix.postRotate(-mRotation);
        rotateMatrix.mapPoints(fpoints);
        dx = fpoints[0];
        dy = fpoints[1];

        if (((GROW_LEFT_EDGE | GROW_RIGHT_EDGE) & edge) == 0)
            dx = 0;
        if (((GROW_TOP_EDGE | GROW_BOTTOM_EDGE) & edge) == 0)
            dy = 0;

        xDelta = dx * (mCropRect.width() / mDrawRect.width());
        yDelta = dy * (mCropRect.height() / mDrawRect.height());

        boolean is_left = UIUtils.checkBits(edge, GROW_LEFT_EDGE);
        boolean is_top = UIUtils.checkBits(edge, GROW_TOP_EDGE);

        float delta;

        if (Math.abs(xDelta) >= Math.abs(yDelta)) {
            delta = xDelta;
            if (is_left) {
                delta *= -1;
            }
        } else {
            delta = yDelta;
            if (is_top) {
                delta *= -1;
            }
        }

        Log.d(LOG_TAG, "x: " + xDelta + ", y: " + yDelta + ", final: " + delta);

        growBy(delta);

        invalidate();
        // mContext.invalidate( getInvalidationRect() );
    }
}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:65,代码来源:MyHighlightView.java

示例15: onDraw

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    float progress = mProgress;
    int c1 = canvas.save();
    int len = mItemList.size();

    for (int i = 0; i < len; i++) {

        canvas.save();
        StoreHouseBarItem storeHouseBarItem = mItemList.get(i);
        float offsetX = mOffsetX + storeHouseBarItem.midPoint.x;
        float offsetY = mOffsetY + storeHouseBarItem.midPoint.y;

        if (mIsInLoading) {
            storeHouseBarItem.getTransformation(getDrawingTime(), mTransformation);
            canvas.translate(offsetX, offsetY);
        } else {

            if (progress == 0) {
                storeHouseBarItem.resetPosition(mHorizontalRandomness);
                continue;
            }

            float startPadding = (1 - mInternalAnimationFactor) * i / len;
            float endPadding = 1 - mInternalAnimationFactor - startPadding;

            // done
            if (progress == 1 || progress >= 1 - endPadding) {
                canvas.translate(offsetX, offsetY);
                storeHouseBarItem.setAlpha(mBarDarkAlpha);
            } else {
                float realProgress;
                if (progress <= startPadding) {
                    realProgress = 0;
                } else {
                    realProgress = Math.min(1, (progress - startPadding) / mInternalAnimationFactor);
                }
                offsetX += storeHouseBarItem.translationX * (1 - realProgress);
                offsetY += -mDropHeight * (1 - realProgress);
                Matrix matrix = new Matrix();
                matrix.postRotate(360 * realProgress);
                matrix.postScale(realProgress, realProgress);
                matrix.postTranslate(offsetX, offsetY);
                storeHouseBarItem.setAlpha(mBarDarkAlpha * realProgress);
                canvas.concat(matrix);
            }
        }
        storeHouseBarItem.draw(canvas);
        canvas.restore();
    }
    if (mIsInLoading) {
        invalidate();
    }
    canvas.restoreToCount(c1);
}
 
开发者ID:qianxinyi,项目名称:DripUltraRefreshWithLoad,代码行数:57,代码来源:StoreHouseFooter.java


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