title: How to convert imageview to bytearray in kotlin
body: <p>How to convert imageview to bytearray kotlin android</p>
  
  <p>In java</p>
  
  <pre><code>Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();
  ByteArrayOutputStream stream=new ByteArrayOutputStream();
  bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream);
  byte[] image=stream.toByteArray();
  
  return image
  </code></pre>