title: Android: Resize an JPEG from SD Card without losing quality
body: <p>Usually I find everything I need using the search function of StackO. But now (success less) I’m really trying hard to resize a JPEG from SD Card without getting bad quality. As follows, you can see that the original Image is clean and perfectly readable. After resizing I will always get a blurred result.</p>
  
  <p>Original: <a href="https://www.dropbox.com/s/l5h4cdkz29vkapw/signature.jpg?dl=0" rel="nofollow">https://www.dropbox.com/s/l5h4cdkz29vkapw/signature.jpg?dl=0</a></p>
  
  <p>Scaled:   <a href="https://www.dropbox.com/s/tobijbu5hisf9rz/signature_small.jpg?dl=0" rel="nofollow">https://www.dropbox.com/s/tobijbu5hisf9rz/signature_small.jpg?dl=0</a></p>
  
  <p>At the following code passage you can see everything I tried without success (I hope I am wrong, but I think this passage includes all the really useable answers from StackO.) :</p>
  
  <pre><code> public void saveSignature(View view) throws IOException {
      image = signature.getImage();
      File sd = Environment.getExternalStorageDirectory();
      File final_location = new File(sd, "signature.jpg");
  
      try {
          if (sd.canWrite()) {
              final_location.createNewFile();
              OutputStream os = new FileOutputStream(final_location);
  
              image.compress(Bitmap.CompressFormat.JPEG, 100, os);
              os.close();
  
              //Bitmap resized = Bitmap.createScaledBitmap(image,(int)(image.getWidth()*0.4),(int)(image.getHeight()*0.4), false);
              //Bitmap resized = Bitmap.createScaledBitmap(image, 300,75, false);
  
              BitmapFactory.Options bmOptions = new BitmapFactory.Options();
  
              // "works but Color ist gray from sampling" bmOptions.inSampleSize = 5;
  
              final_location = new File(sd, "signature_small.jpg");
              final_location.createNewFile();
              os = new FileOutputStream(final_location);
  
              Bitmap b= BitmapFactory.decodeFile(sd +"/signature.jpg",bmOptions);
              Bitmap out = Bitmap.createScaledBitmap(b, 349, 86, true); //also tyed false (without any Change)
  
              out.compress(Bitmap.CompressFormat.JPEG, 100, os);
              os.close();
          }
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>It would be nice to get some answers or links to samples for Android (4.0 and higher).</p>
  
  <p>Thanks for your help in advance,
  Tough!! </p>