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?

1

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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?
its image quality factor if you want high quality image use 100 otherwise relative value according you requirment.
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...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.