Code example for Bitmap

Methods: createBitmapgetHeightgetWidthrecycle

0
	} 
 
	public static Bitmap rotate(Bitmap b, int degrees) {
		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) {
					b.recycle();
					b = b2;
				} 
			} catch (OutOfMemoryError ex) {
				// We have no memory to rotate. Return the original bitmap. 
			} 
		} 
		return b;
	} 
Experience pair programming with AI  Get Codota for Java