title: Poor picture quality from Custom Camera
body: <p>Currently I'm using a custom camera application, the preview looks just fine. But when I take the picture and display it in my other activity the picture has decreased with like 80%. Anyone knows why this is happening?  Also in gallery the quality is poor.
  I'm using the Camera API Demo from <a href="http://developer.android.com/guide/topics/media/camera.html" rel="nofollow noreferrer">android</a>.</p>
  
  <p>My parameters :</p>
  
  <pre><code>public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
      parameters = mCamera.getParameters();
  
  
      parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
      parameters.setFlashMode(Parameters.FLASH_MODE_AUTO);
      parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
      parameters.setJpegQuality(100);
      parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
      parameters.setRotation(90);
      Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
      if (display.getRotation() == Surface.ROTATION_0) {
          mCamera.setDisplayOrientation(90);
      } else if (display.getRotation() == Surface.ROTATION_270) {
          mCamera.setDisplayOrientation(180);
      }
  
      mCamera.setParameters(parameters);
  
      mCamera.startPreview();
  }
  </code></pre>
  
  <p>Code saving image: </p>
  
  <pre><code>private PictureCallback mPicture = new PictureCallback() {
      private String TAG = "DocsPro";
  
      @Override
      public void onPictureTaken(byte[] data, Camera camera) {
  
          File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
          if (pictureFile == null) {
              Log.d(TAG, "Error creating media file, check storage permissions : PICTURE FILE IS NULL");
              return;
          }
  
          try {
              FileOutputStream fos = new FileOutputStream(pictureFile);
              fos.write(data);
              fos.close();
              String filepath = pictureFile.getAbsolutePath();
              Intent edit = new Intent(TakePhoto.this, EditPhoto.class);
              edit.putExtra("filepath", filepath);
              startActivity(edit);
              finish();
          } catch (FileNotFoundException e) {
              Log.d(TAG, "File not found: " + e.getMessage());
          } catch (IOException e) {
              Log.d(TAG, "Error accessing file: " + e.getMessage());
          }
      }
  };
  
  private static File getOutputMediaFile(int type) {
      // To be safe, you should check that the SDCard is mounted
      // using Environment.getExternalStorageState() before doing this.
  
      File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
              Environment.DIRECTORY_PICTURES), "DocsPro");
      // This location works best if you want the created images to be shared
      // between applications and persist after your app has been uninstalled.
  
      // Create the storage directory if it does not exist
      if (!mediaStorageDir.exists()) {
          if (!mediaStorageDir.mkdirs()) {
              Log.d("MyCameraApp", "failed to create directory");
              return null;
          }
      }
  
      // Create a media file name
      String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
      File mediaFile;
      if (type == MEDIA_TYPE_IMAGE) {
          mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                  "IMG_" + timeStamp + ".jpg");
      } else {
          return null;
      }
  
      return mediaFile;
  }
  </code></pre>