Code example for ByteArrayOutputStream

Methods: sizetoByteArray

		Bitmap b = null;
		Size s = parameters.getPreviewSize();
		YuvImage yuvimage = new YuvImage(buffer, ImageFormat.NV21, s.width, s.height, null);
		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
		yuvimage.compressToJpeg(new Rect(x, y, width, height), 100, outStream); // make JPG
		b = BitmapFactory.decodeByteArray(outStream.toByteArray(), 0, outStream.size()); // decode JPG
		yuvimage = null;
		outStream = null;
		return b;
	private void updateBufferSize() { 
		buffer = null;
		// prepare a buffer for copying preview data to 
		int h = camera.getParameters().getPreviewSize().height;
		int w = camera.getParameters().getPreviewSize().width;
Stop searching for code, let great code find you!  Add Codota to your java IDE