title: Save image in original form and without compressing
body: <p>I want to save the image without compressing it and want to save it in it's original form i.e. when image is compressed the image size decreases and image become small. I am using native camera for this purpose. I am working in <code>android studio</code>. I am making an app in which i am using a camera to save image. But the image is compressed and is very small and very lower quality.</p>
  
  <p>Below is my code for saving image </p>
  
  <pre><code> @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  
      final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);
      if(requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE)
      {
          if(resultCode == Activity.RESULT_OK)
          {
              Bitmap bmp = (Bitmap)data.getExtras().get("data");
              ByteArrayOutputStream stream = new ByteArrayOutputStream();
  
              bmp.compress(Bitmap.CompressFormat.JPEG, 100, stream);
              byte[] byteArray = stream.toByteArray();
  
              // convert byte array to Bitmap
              Bitmap bitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
  
              if(isStoragePermissionGranted())
              {
                  SaveImage(bitmap);
              }
  
  
          }
      }else {
          switch (requestCode) {
              case 1000:
                  switch (resultCode) {
                      case Activity.RESULT_OK:
                          // All required changes were successfully made
                          getLocation();
                          break;
                      case Activity.RESULT_CANCELED:
                          // The user was asked to change settings, but chose not to
                          Toast.makeText(this, "Location Service not Enabled", Toast.LENGTH_SHORT).show();
                          break;
                      default:
                          break;
                  }
                  break;
          }
  
      }
  
  
  }
  
  private void SaveImage(Bitmap finalBitmap) {
  
      File storageDir = new File (String.valueOf(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)));
      String root = storageDir + Environment.getExternalStorageDirectory().getAbsolutePath().toString();
      Log.v(LOG_TAG, root);
      File myDir = new File(root + "/captured_images");
      if (!myDir .exists())
      {
          myDir .mkdirs();
      }
      Random generator = new Random();
      int n = 1000;
      n = generator.nextInt(n);
      String fname = "Image-" + n + ".jpg";
      File file = new File(myDir,fname);
      try {
          file.createNewFile();
          MediaScannerConnection.scanFile(getApplicationContext(), new String[]  {file.getPath()} , new String[]{"image/*"}, null);
          FileOutputStream out = new FileOutputStream(file);
          finalBitmap.compress(Bitmap.CompressFormat.JPEG,100,out);
          out.flush();
          out.close();
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  
  }
  </code></pre>
  
  <p><strong>Update 1</strong></p>
  
  <p>For more understanding i am putting my <code>onClick</code> method</p>
  
  <pre><code>   btn_camera.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              // Check permission for camera
  
              if(ActivityCompat.checkSelfPermission(MainActivity.this, CAMERA)
                      != PackageManager.PERMISSION_GRANTED)
              {
                  // Check Permissions Now
                  // Callback onRequestPermissionsResult interceptado na Activity MainActivity
  
                  ActivityCompat.requestPermissions(MainActivity.this,
                          new String[]{CAMERA},
                          MainActivity.REQUEST_CAMERA);
              }
              else {
  
  
                  Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                  startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE );
  
              }
  
  
          }
      });
  </code></pre>
  
  <p>I searched the solution and found that i can use <a href="https://stackoverflow.com/a/32940449/6854117">AndroidBitmapUtil
  </a> class so i copy and pasted this <a href="https://github.com/ultrakain/AndroidBitmapUtil/blob/master/src/com/ultrasonic/android/image/bitmap/util/AndroidBmpUtil.java" rel="noreferrer">class</a> into my project i.e. i created a new class. But i don't know how to use it. Although it is described that i can save image by doing <code>new AndroidBmpUtil().save(bmImage, file);</code>. But again i can't match with my code :(</p>
  
  <p>Any help would be highly appreciated</p>