Android resize a bitmap

Here is a snippet to scale down a bitmap – the original bitmap still needs to fit on memory though

InputStream bitmap = mContext.getAssets().open("image.file");
Bitmap scaledBitmap= Bitmap.createScaledBitmap(BitmapFactory.decodeStream(bitmap), 120, 120, false);

Android: Rotate a bitmap

Here is a small sample that will rotate a bitmap.

Bitmap animation = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.eye_rotate, mBitmapOptions);
Bitmap bitmap = Bitmap.createBitmap(animation.getWidth(), animation.getHeight(), BITMAP_CONFIG);
Matrix matrix = new Matrix();
matrix.setTranslate(0, 0);
matrix.postRotate(degrees, (animation.getWidth()/2), (animation.getHeight()/2));        	
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
int xPos = 0;
int yPos = 0;
Rect src = new Rect(xPos, yPos, xPos + animation.getWidth(), yPos + animation.getHeight());
Rect dst = new Rect(0, 0, animation.getWidth(), animation.getHeight());
canvas.drawBitmap(mBackground, src, dst, paint);
canvas.drawBitmap(animation, matrix, null);