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

intcomputePictureRotation()
compute Picture Rotation
if (mCameraType == 1 && (mCameraAngle == 90 || mCameraAngle == 270)) {
    return (180 + mCameraAngle) % 360;
return mCameraAngle;
intGetExifOrientation(String filepath)
Get Exif Orientation
int degree = 0;
ExifInterface exif = null;
try {
    exif = new ExifInterface(filepath);
} catch (IOException e) {
    Log.e(TAG, "cannot read exif");
    e.printStackTrace();
if (exif != null) {
    int orientation = exif.getAttributeInt(
            ExifInterface.TAG_ORIENTATION, -1);
    if (orientation != -1) {
        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_90:
            degree = 90;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            degree = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_270:
            degree = 270;
            break;
return degree;
BitmapreflectionFromBitmap(Bitmap originalBitmap, boolean isFuzzy)
reflection From Bitmap
int width = originalBitmap.getWidth();
int height = originalBitmap.getHeight();
Matrix matrix = new Matrix();
matrix.preScale(1, -1);
Bitmap reflectionBitmap = Bitmap.createBitmap(originalBitmap, 0, 0,
        width, height, matrix, false);
if (isFuzzy) {
    Canvas canvasFuzzy = new Canvas(reflectionBitmap);
...
Bitmaprotate(Bitmap bitmap, int angle)
rotate
Matrix m = new Matrix();
int width = bitmap.getWidth();
int height = bitmap.getHeight();
m.setRotate(angle);
return Bitmap.createBitmap(bitmap, 0, 0, width, height, m, true);
Bitmaprotate(Bitmap bitmap, int degrees)
Rotates the bitmap by the specified degree.
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) {
...
BitmaprotateBitmap(Bitmap bitmap, float degrees)
rotate Bitmap
Bitmap mBitmap = null;
try {
    Matrix m = new Matrix();
    m.setRotate(degrees % 360);
    mBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
            bitmap.getHeight(), m, false);
} catch (Exception e) {
    e.printStackTrace();
...
BitmaprotateBitmap(Bitmap input, int degrees)
rotate Bitmap
RectF srcRect = new RectF(0, 0, input.getWidth(), input.getHeight());
Matrix matrix = new Matrix();
matrix.setRotate(degrees);
matrix.mapRect(srcRect);
matrix.postTranslate(0 - srcRect.left, 0 - srcRect.top);
Bitmap targetBitmap = Bitmap.createBitmap(
        Math.round(srcRect.width()), Math.round(srcRect.height()),
        Bitmap.Config.RGB_565);
...
BitmaprotateBitmapTranslate(Bitmap bitmap, float degrees)
rotate Bitmap Translate
Bitmap mBitmap = null;
int width;
int height;
try {
    Matrix matrix = new Matrix();
    if ((degrees / 90) % 2 != 0) {
        width = bitmap.getWidth();
        height = bitmap.getHeight();
...
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)
...
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) {
...