Rotate

One of the built-in methods is the setRotation method. It takes in a float representing the degrees of rotation. Positive values rotate the image clockwise and negative values rotate it counter-clockwise around the default point (0,0), which is the top left corner of the image as illustrated in Figure 3-8.

Matrix matrix = new Matrix(); matrix.setRotate(15); canvas.drawBitmap(bmp, matrix, paint);

(UHO

Choose Picture

Choose Picture ml

Figure 3-8. Rotation around the default point (0,0)

Alternatively, the setRotation method can be called with the degrees of rotation and the points around which to rotate. Choosing the center point on the image might yield results more in line with what we are looking for as shown in Figure 3-9.

matrix.setRotate(15,bmp.getWidth()/2,bmp.getHeight()/2);

LîJWU Siffla 10:57 am

Choose Picture

Choose Picture

fi

Jr 1 ■ ^ W

Wkt

s' f 1

IT

Figure 3-9. Rotation around the mid-point of the image

Was this article helpful?

0 0

Post a comment