code: public static byte[] encodeBitmapToArray(Bitmap bitmap, Bitmap.CompressFormat format) {
          ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
          bitmap.compress(format, 0, outputStream);
          return outputStream.toByteArray();
  
      }
docs: Encodes a bitmap to a byte array.
  
  @param bitmap the bitmap to compress
  @param format the compression format for the Bitmap
  @return {@code byte[]} object