title: how to covert image view into bitmap in android studio?
body: <p>Can anyone tell me how to convert imageview to bitmap? In my app, i'm accessing the gallery and getting a bitmap of a picture into an imageview, then using picasso, i'm resizing the images that are too big to directly uploaded to parse. I can resize the image in the image view using picasso but how do i get the bitmap from the image view to upload to parse? this is my code..</p>
  
  <pre><code> public static final int IMAGE_GALLERY_REQUEST = 20;
      private ImageView imgPicture;
      public Bitmap image; 
  
  
  
   public void openGallery(View view){
  
  
      Intent intent = new Intent();
      intent.setType("image/*");
      intent.setAction(Intent.ACTION_GET_CONTENT);//
      startActivityForResult(Intent.createChooser(intent, "Select Picture"),IMAGE_GALLERY_REQUEST);
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (resultCode == RESULT_OK) {
          // if we are here, everything processed successfully.
          if (requestCode == IMAGE_GALLERY_REQUEST) {
  
              Uri imageUri = data.getData();
  
  
              InputStream inputStream;
  
  
              try {
                  inputStream = getContentResolver().openInputStream(imageUri);
  
  
                   image = BitmapFactory.decodeStream(inputStream);
  
  
  
                  height= image.getHeight();
                  h= String.valueOf(height);
  
                  width= image.getWidth();
                  w= String.valueOf(width);
  
  
  
                 if (width&gt;800 || height&gt;600)
                  {
  
  
                      Picasso.with(this)
                              .load(imageUri)
                              .resize(800,600)
                              .centerCrop()
                              .into(imgPicture);
                     // imgPicture.setImageBitmap(image);
                       //what should i write here to convert this imageview to bitmap? and then later use that bitmap to upload the image to parse?
  
  
                  }
                  else
                  {
                      //do nothing
                      imgPicture.setImageBitmap(image);
                  }
  
  
              } catch (FileNotFoundException e) {
                  e.printStackTrace();
                  // show a message to the user indictating that the image is unavailable.
                  Toast.makeText(this, "Unable to open image", Toast.LENGTH_LONG).show();
              }
  
          }
      }
  }
  </code></pre>