title: How to convert URI to bitmap?
body: <p>I Am Making An Image Filter App And Before Applying Filter I Will Crop The Image As Square, I Can Crop The Image Using Soundcloud Library Like This:-</p>
  
  <pre><code>private void beginCrop(String sources) {
      img_name = "cropped"+System.currentTimeMillis();
      Uri destination = Uri.fromFile(new File(getCacheDir(), "cropped"+System.currentTimeMillis()));
      Uri source = Uri.parse("file://"+sources);
      Crop.of(source, destination).withAspect(200,200).start(this);
  }
  
  private void handleCrop(int resultCode, Intent result) {
      if (resultCode == RESULT_OK) {
          Toast.makeText(this,Crop.getOutput(result).toString(), Toast.LENGTH_SHORT).show();
          Intent intent = new Intent(AlbumActivity.this,FilterImageActivity
                  .class);
          intent.putExtra("output_image",Crop.getOutput(result).toString());
          startActivity(intent);
      } else if (resultCode == Crop.RESULT_ERROR) {
          Toast.makeText(this, Crop.getError(result).getMessage(), Toast.LENGTH_SHORT).show();
      }
  }}
  </code></pre>
  
  <p>And On The Next Activity Which Is FilterImageActivity.java:-</p>
  
  <pre><code>     @Override
      protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_filter_image);
  
          String uri = getIntent().getStringExtra("output_image");
          setImageDir(uri);
  }
  </code></pre>
  
  <p>And The Function setImageDir():-</p>
  
  <pre><code> private void setImageDir(String uri)
      {
          Bitmap bitmap = convetBitmap(uri);
  
          // clear bitmap memory
         /* originalImage.recycle();
          finalImage.recycle();
          finalImage.recycle();*/
  
          originalImage = bitmap.copy(Bitmap.Config.ARGB_8888, true);
          filteredImage = originalImage.copy(Bitmap.Config.ARGB_8888, true);
          finalImage = originalImage.copy(Bitmap.Config.ARGB_8888, true);
          imagePreview.setImageBitmap(originalImage);
          bitmap.recycle();
  
          // render selected image thumbnails
          filtersListFragment.prepareThumbnail(originalImage);
      }
  </code></pre>
  
  <p>And The Function convertBitmap():-</p>
  
  <pre><code> private Bitmap convetBitmap(final String uri)
     {
         final Bitmap[] bitmap = {null};
         Thread task = new Thread()
         {
             @Override
             public void run()
             {
                 try {
                     bitmap[0] =   Glide.with(getApplicationContext()).asBitmap().load(Uri.parse(uri)).into(100,100).get();
                 } catch (InterruptedException | ExecutionException e) {
                     e.printStackTrace();
                 }
             }
         };
  
         task.start();
  
  
     return bitmap[0];
  </code></pre>
  
  <p>}</p>
  
  <p>Image Is Cropped And Saved To Directory For Example </p>
  
  <blockquote>
    <p>file:///data/user/0/com.dev.pigeon/cache/cropped1518332591373</p>
  </blockquote>
  
  <p>But It Gives An Error</p>
  
  <pre><code> Attempt to invoke virtual method 'android.graphics.Bitmap android.graphics.Bitmap.copy(android.graphics.Bitmap$Config, boolean)' on a null object reference
  </code></pre>
  
  <p>Maybe The URI is Not Converting Into Bitmap Please Any Solution???</p>