Code example for Camera.Parameters

Methods: getPreviewFormat

      camera.setPreviewCallback(new PreviewCallback() { 
        // Called for each frame previewed 
        public void onPreviewFrame(byte[] data, Camera camera) { 
	        		 YuvImage yuv_image = new YuvImage(data,param.getPreviewFormat() , size.width, size.height, null); // all bytes are in YUV format therefore to use the YUV helper functions we are putting in a YUV object 
	        		 Rect rect = new Rect(0, 0, size.width, size.height);  
	                 ByteArrayOutputStream output_stream = new ByteArrayOutputStream();  
	                 yuv_image.compressToJpeg(rect, 80, output_stream);// image has now been converted to the jpg format and bytes have been written to the output_stream object
	                 byte [] tmp=output_stream.toByteArray();//getting the byte array
	                 outStream.writeInt(tmp.length);// sending the size of the array 
	                 outStream.write(tmp);// writing the array to the socket output stream
					Log.d(TAG, "onPreviewFrame - wrote bytes: "+ data.length);
        }catch(Exception e){e.printStackTrace();}