2
Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.images);
ByteArrayOutputStream stream=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); // what 90 does ??
byte[] image=stream.toByteArray();

What does 90 in bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); mean?

Yury Fedorov
  • 14,508
  • 6
  • 50
  • 66
FaisalAhmed
  • 3,469
  • 7
  • 46
  • 76
  • 1
    Possible duplicate of [How to convert image into byte array and byte array to base64 String in android?](http://stackoverflow.com/questions/10513976/how-to-convert-image-into-byte-array-and-byte-array-to-base64-string-in-android) – Harshad Pansuriya Jun 30 '16 at 07:23

2 Answers2

3
public boolean compress (Bitmap.CompressFormat format, int quality, OutputStream stream)

Quality:

Hint to the compressor, 0-100. 0 meaning compress for small size, 100 meaning compress for max quality. Some formats, like PNG which is lossless, will ignore the quality setting.

Sohail Zahid
  • 8,099
  • 2
  • 25
  • 41
  • what is difference between if i give value 50 and 90 . I am still confuse . which compress qaulity is better . and how should i decide right qaulity that is suitable for me? – FaisalAhmed Jun 30 '16 at 07:27
  • 1
    its image quality factor if you want high quality image use 100 otherwise relative value according you requirment. – Sohail Zahid Jun 30 '16 at 07:29
1
boolean compress (Bitmap.CompressFormat format, 
                int quality, 
                OutputStream stream)

Here, Quality is an integer type which is used to hint to the compressor, 0-100.
Here, 0 means compress for minimum quality, 100 meaning compress for max quality.
It totally depends upon your requirement.. that in what quality you want your image after compression.(Which effects on the size of the image also)
Some formats, like PNG (lossless ), will ignore the quality setting.

For more Information click here...

Saurabh Vardani
  • 1,821
  • 2
  • 18
  • 33