Code example for ByteArrayOutputStream

Methods: size, toByteArray

0
	 * @param compression The compression ratio 0-100. 
	 * @return The compressed bitmap. 
	 */ 
	public static Bitmap compress(Bitmap bm, int compression)
	{ 
		ByteArrayOutputStream bitmapOutputStream = new ByteArrayOutputStream();
		bm.compress(CompressFormat.JPEG, compression, bitmapOutputStream);
		 
		if (mRecycleBitmaps)
		{ 
			bm.recycle();
		} 
		 
		return BitmapFactory.decodeByteArray(bitmapOutputStream.toByteArray(), 0, bitmapOutputStream.size());		
	} 
	 
	/** 
	 * Rotates a bitmap. Original bitmap is recycled after this method is called. 
	 * @param bm The bitmap to rotate 
	 * @param degrees The degrees to rotate at. 0-360 clockwise. 
	 * @return The rotated bitmap