Code example for ByteArrayOutputStream

Methods: toByteArray

		TiDrawableReference ref;
		try { 
			ref = TiDrawableReference.fromBlob(getActivity(), blob);
			image = ref.getBitmap();
			bos = new ByteArrayOutputStream();
			if (image.compress(CompressFormat.JPEG, (int)(compressionQuality * 100), bos)) {
				byte[] data = bos.toByteArray();
				BitmapFactory.Options bfOptions = new BitmapFactory.Options();
				bfOptions.inPurgeable = true;
				bfOptions.inInputShareable = true;
				result = TiBlob.blobFromData(data, "image/jpeg");
				coerceDimensionsIntoBlob(image, result);
		} catch (OutOfMemoryError e) {
			Log.e(LCAT, "Received an OutOfMemoryError! The image is too big to compress all at once. Consider using the \"compressToFile\" method instead.");
		finally { 
            // [MOD-309] Free up memory to work around issue in Android 
			if (image != null) {
Connect your IDE to all the code out there  Get Codota for Java