Diyor Ismatullaev
Diyor Ismatullaev

Reputation: 61

Bitmap to jpeg without saving to the file system

How to compress bitmap to jpeg? Storing in a file system is unacceptable.

Upvotes: 0

Views: 379

Answers (1)

Swanand
Swanand

Reputation: 507

Just use below code!

Bitmap bmp = null;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] byteArray = stream.toByteArray();

Upvotes: 1

Related Questions