Reputation: 3291
I use the following code to save the captured image:
Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length);
FileOutputStream fos = new FileOutputStream(pictureFile);
bm.compress(Bitmap.CompressFormat.JPEG, 100, fos);
Since I will have further implementaion, I would like to check the physical size of bitmap when it saved in SD card.
If the size is over 1mb, I would like to scale it before saving it as jpeg.
How to do it?
Please give example. Thanks.
Upvotes: 0
Views: 111
Reputation: 39406
bm.compress
does not know the size of the element prior to writing it. what you could do is write it to a byteoutputstream, then check the size and act accordingly
Upvotes: 1