Android Utililty Methods Bitmap Rotate

List of utility methods to do Bitmap Rotate

Description

The list of methods to do Bitmap Rotate are organized into topic(s).

Method

BitmapfixBitmapOrientation(Uri uri, Bitmap bmp)
fix Bitmap Orientation
ExifInterface ei = new ExifInterface(uri.getPath());
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION,
        ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
    return rotateBitmap(bmp, 90);
case ExifInterface.ORIENTATION_ROTATE_180:
    return rotateBitmap(bmp, 180);
...
Bitmaprotate(Bitmap b, int degrees)
rotate
return rotateAndMirror(b, degrees, false);
Bitmaprotate(Bitmap bitmap, int degree)
rotate
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Matrix mtx = new Matrix();
mtx.postRotate(degree);
Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx,
        true);
bitmap.recycle();
return rotatedBitmap;
...
BitmaprotateAndMirror(Bitmap b, int degrees, boolean mirror)
rotate And Mirror
if ((degrees != 0 || mirror) && b != null) {
    Matrix m = new Matrix();
    if (mirror) {
        m.postScale(-1, 1);
        degrees = (degrees + 360) % 360;
        if (degrees == 0 || degrees == 180) {
            m.postTranslate(b.getWidth(), 0);
        } else if (degrees == 90 || degrees == 270) {
...
BitmaprotateBitmap(Bitmap b, int degrees)
rotate Bitmap
if (degrees != 0 && b != null) {
    Matrix m = new Matrix();
    m.setRotate(degrees, (float) b.getWidth() / 2,
            (float) b.getHeight() / 2);
    try {
        Bitmap b2 = Bitmap.createBitmap(b, 0, 0, b.getWidth(),
                b.getHeight(), m, true);
        if (b != b2) {
...
BitmaprotateBitmap(Bitmap source, float angle)
rotate Bitmap
Matrix matrix = new Matrix();
matrix.postRotate(angle);
return Bitmap.createBitmap(source, 0, 0, source.getWidth(),
        source.getHeight(), matrix, true);
BitmaprotateBitmap(Bitmap source, int rotation, boolean recycle)
rotate Bitmap
if (rotation == 0)
    return source;
int w = source.getWidth();
int h = source.getHeight();
Matrix m = new Matrix();
m.postRotate(rotation);
Bitmap bitmap = Bitmap.createBitmap(source, 0, 0, w, h, m, true);
if (recycle)
...
BitmaprotatePic(Bitmap bitmap, int degree)
rotate Pic
Matrix matrix = new Matrix();
matrix.postRotate(degree);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix,
        true);
Bitmaprotation(Bitmap source, int degrees)
rotation
if (null == source || source.isRecycled()) {
    return null;
Matrix matrix = new Matrix();
matrix.postRotate(degrees);
Bitmap rotation = Bitmap.createBitmap(source, 0, 0,
        source.getWidth(), source.getHeight(), matrix, true);
if (rotation != null) {
...
BitmapGetRotatedBitmap(Bitmap bitmap, int degrees)
Get Rotated Bitmap
if (degrees != 0 && bitmap != null) {
    Matrix m = new Matrix();
    m.setRotate(degrees, (float) bitmap.getWidth() / 2,
            (float) bitmap.getHeight() / 2);
    try {
        Bitmap b2 = Bitmap.createBitmap(bitmap, 0, 0,
                bitmap.getWidth(), bitmap.getHeight(), m, true);
        if (bitmap != b2) {
...