本文整理了Java中android.graphics.Matrix.preRotate()
方法的一些代码示例,展示了Matrix.preRotate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.preRotate()
方法的具体详情如下:
包路径:android.graphics.Matrix
类名称:Matrix
方法名:preRotate
暂无
代码示例来源:origin: steelkiwi/cropiwa
private static Bitmap ensureCorrectRotation(Context context, Uri uri, Bitmap bitmap) {
int degrees = exifToDegrees(extractExifOrientation(context, uri));
if (degrees != 0) {
Matrix matrix = new Matrix();
matrix.preRotate(degrees);
return transformBitmap(bitmap, matrix);
}
return bitmap;
}
代码示例来源:origin: square/picasso
int exifTranslation = getExifTranslation(exifOrientation);
if (exifRotation != 0) {
matrix.preRotate(exifRotation);
if (exifRotation == 90 || exifRotation == 270) {
代码示例来源:origin: airbnb/lottie-android
/**
* TODO: see if we can use this for the main {@link #getMatrix()} method.
*/
public Matrix getMatrixForRepeater(float amount) {
if (isIdentity) {
return matrix;
}
PointF position = this.position.getValue();
PointF anchorPoint = this.anchorPoint.getValue();
ScaleXY scale = this.scale.getValue();
float rotation = this.rotation.getValue();
matrix.reset();
matrix.preTranslate(position.x * amount, position.y * amount);
matrix.preScale(
(float) Math.pow(scale.getScaleX(), amount),
(float) Math.pow(scale.getScaleY(), amount));
matrix.preRotate(rotation * amount, anchorPoint.x, anchorPoint.y);
return matrix;
}
代码示例来源:origin: wangdan/AisenWeiBo
@Override
protected void onSizeChanged(int width, int height, int oldw, int oldh) {
int centerX = width / 2;
int centerY = height / 2;
innerPadding = (int) (paramInnerPadding * width / 100);
outerPadding = (int) (paramOuterPadding * width / 100);
arrowPointerSize = (int) (paramArrowPointerSize * width / 100);
valueSliderWidth = (int) (paramValueSliderWidth * width / 100);
outerWheelRadius = width / 2 - outerPadding - arrowPointerSize;
innerWheelRadius = outerWheelRadius - valueSliderWidth;
colorWheelRadius = innerWheelRadius - innerPadding;
outerWheelRect.set(centerX - outerWheelRadius, centerY - outerWheelRadius, centerX + outerWheelRadius, centerY + outerWheelRadius);
innerWheelRect.set(centerX - innerWheelRadius, centerY - innerWheelRadius, centerX + innerWheelRadius, centerY + innerWheelRadius);
colorWheelBitmap = createColorWheelBitmap(colorWheelRadius * 2, colorWheelRadius * 2);
gradientRotationMatrix = new Matrix();
gradientRotationMatrix.preRotate(270, width / 2, height / 2);
colorViewPath.arcTo(outerWheelRect, 270, -180);
colorViewPath.arcTo(innerWheelRect, 90, 180);
valueSliderPath.arcTo(outerWheelRect, 270, 180);
valueSliderPath.arcTo(innerWheelRect, 90, -180);
}
代码示例来源:origin: siyamed/android-shape-imageview
matrix.preRotate(angle);
matrix.preTranslate(-cx, -cy);
代码示例来源:origin: robolectric/robolectric
@Test
public void testPreRotate() {
final Matrix matrix = new Matrix();
matrix.preRotate(90.0f);
assertPointsEqual(mapPoint(matrix, 0.0f, 1.0f), new PointF(-1.0f, 0.0f));
matrix.preRotate(90.0f);
assertPointsEqual(mapPoint(matrix, 0.0f, 1.0f), new PointF(0.0f, -1.0f));
matrix.preRotate(90.0f);
assertPointsEqual(mapPoint(matrix, 0.0f, 1.0f), new PointF(1.0f, 0.0f));
matrix.preRotate(90.0f);
assertPointsEqual(mapPoint(matrix, 0.0f, 1.0f), new PointF(0.0f, 1.0f));
matrix.setTranslate(1.0f, 2.0f);
matrix.preRotate(45.0f, 0.0f, 1.0f);
assertPointsEqual(mapPoint(matrix, 0.0f, 1.0f), new PointF(1.0f, 3.0f));
}
代码示例来源:origin: Yalantis/uCrop
matrix.preRotate(exifDegrees);
代码示例来源:origin: robolectric/robolectric
@Test
public void preOperationsAreStacked() {
Matrix m = new Matrix();
m.preRotate(4, 8, 15);
m.preTranslate(16, 23);
m.preSkew(42, 108);
assertThat(shadowOf(m).getPreOperations()).containsExactly(
"skew 42.0 108.0",
"translate 16.0 23.0",
"rotate 4.0 8.0 15.0"
);
}
代码示例来源:origin: airbnb/lottie-android
public Matrix getMatrix() {
if (isIdentity) {
return matrix;
}
matrix.reset();
PointF position = this.position.getValue();
if (position.x != 0 || position.y != 0) {
matrix.preTranslate(position.x, position.y);
}
float rotation = ((FloatKeyframeAnimation) this.rotation).getFloatValue();
if (rotation != 0f) {
matrix.preRotate(rotation);
}
ScaleXY scaleTransform = this.scale.getValue();
if (scaleTransform.getScaleX() != 1f || scaleTransform.getScaleY() != 1f) {
matrix.preScale(scaleTransform.getScaleX(), scaleTransform.getScaleY());
}
PointF anchorPoint = this.anchorPoint.getValue();
if (anchorPoint.x != 0 || anchorPoint.y != 0) {
matrix.preTranslate(-anchorPoint.x, -anchorPoint.y);
}
return matrix;
}
代码示例来源:origin: bmarrdev/android-DecoView-charting
gradient = new SweepGradient(mBounds.centerX(), mBounds.centerY(), colors, positions);
Matrix gradientRotationMatrix = new Matrix();
gradientRotationMatrix.preRotate(mAngleStart - ((360f - mAngleSweep) / 2), mBounds.centerX(), mBounds.centerY());
gradient.setLocalMatrix(gradientRotationMatrix);
} else {
代码示例来源:origin: mapsforge/mapsforge
@Override
public void rotate(float theta) {
this.matrix.preRotate((float) Math.toDegrees(theta));
}
代码示例来源:origin: mapsforge/mapsforge
@Override
public void rotate(float theta, float pivotX, float pivotY) {
this.matrix.preRotate((float) Math.toDegrees(theta), pivotX, pivotY);
}
代码示例来源:origin: simplezhli/Tesseract-OCR-Scanner
public static Bitmap preRotateBitmap(Bitmap source, float angle) {
Matrix matrix = new Matrix();
matrix.preRotate(angle);
return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, false);
}
代码示例来源:origin: Lauzy/TicktockMusic
public void stop() {
// if (!isPlaying) {
// return;
// }
// isPlaying = false;
// mRotation = 0;
if (mShaderMatrix != null && mBitmapShader != null) {
mShaderMatrix.preRotate(-mRotation, mBitmapWidth / 2, mBitmapHeight / 2);
mBitmapShader.setLocalMatrix(mShaderMatrix);
}
mHandler.removeCallbacks(mRotationRunnable);
isPlaying = false;
}
代码示例来源:origin: Jamlh/Sample
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.BLACK);
_mPaint.setColor(Color.WHITE);
_mPaint.setTextSize(30);
_mPaint.setFlags(Paint.FAKE_BOLD_TEXT_FLAG);
canvas.drawText(_message, 75, 50, _mPaint);
// 实现图像旋转
Matrix mat = new Matrix();
mat.reset();
mat.setTranslate(15, 100);
mat.preRotate(-_decDegree, 145, 145);
// 绘制图像
canvas.drawBitmap(_compass, mat, _mPaint);
canvas.drawBitmap(_arrow, 152, 73, null);
}
代码示例来源:origin: marianmoldovan/panoramagl
@Override
public PLIImage rotate(float degrees, float px, float py)
{
Matrix matrix = new Matrix();
matrix.preRotate(degrees, px, py);
Bitmap image = Bitmap.createBitmap(mBitmap, 0, 0, mWidth, mHeight, matrix, true);
this.deleteImage();
this.createWithBitmap(image, false);
return this;
}
代码示例来源:origin: marianmoldovan/panoramagl
/**rotate methods*/
@Override
public PLIImage rotate(int angle)
{
if((angle % 90) != 0)
return this;
Matrix matrix = new Matrix();
matrix.preRotate(angle);
Bitmap image = Bitmap.createBitmap(mBitmap, 0, 0, mWidth, mHeight, matrix, true);
this.deleteImage();
this.createWithBitmap(image, false);
return this;
}
代码示例来源:origin: xia-weiyang/MainScreenShow
public void snowRotate() {
if (System.currentTimeMillis() - rotateTime > 10) {
degree += 1;
matrix.reset();
move(this.moveType);
matrix.setTranslate((float) x, (float) y);
matrix.preRotate(degree, cw / 2, ch / 2);
snowScaleChange();
rotateTime = System.currentTimeMillis();
}
}
/*
代码示例来源:origin: WenWangAndroid/ChartManager
private void initShader() {
updateOval();
if (startColor != 0 && endColor != 0) {
// LinearGradient shader = new LinearGradient(rectF2.left, rectF2.top, rectF2.right, rectF2.bottom,
// endColor, startColor, Shader.TileMode.CLAMP);
SweepGradient shader = new SweepGradient(0, 0, new int[]{startColor, endColor}, null);
float rotate = 90f;
Matrix gradientMatrix = new Matrix();
gradientMatrix.preRotate(rotate, 0, 0);
shader.setLocalMatrix(gradientMatrix);
paintProgress.setShader(shader);
}
}
代码示例来源:origin: 1993hzw/Doodle
private void adjustMosaic() {
if (getPen() == DoodlePen.MOSAIC
&& getColor() instanceof DoodleColor) {
DoodleColor doodleColor = ((DoodleColor) getColor());
Matrix matrix = doodleColor.getMatrix();
matrix.reset();
matrix.preScale(1 / getScale(), 1 / getScale(), getPivotX(), getPivotY()); // restore scale
matrix.preTranslate(-getLocation().x * getScale(), -getLocation().y * getScale());
matrix.preRotate(-getItemRotate(), getPivotX(), getPivotY());
matrix.preScale(doodleColor.getLevel(), doodleColor.getLevel());
doodleColor.setMatrix(matrix);
refresh();
}
}
内容来源于网络,如有侵权,请联系作者删除!