0

I need to give the user possibility to share his high score. I took an image (PNG) and wrote the high score on it on it. Can I convert BitMap to PNG and share it without saving the file?

user5238167
  • 1
  • 1
  • 1

1 Answers1

0

You can use the boolean compress(Bitmap.CompressFormat format, int quality, OutputStream stream) of the Bitmap class.

ByteArrayOutputStram baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] png = baos.toByteArray();

You will have the byte[] contained the image in png format. You can then use any API you want to share that image.

sonic
  • 1,894
  • 1
  • 18
  • 22