I am using Bitmap's compress()
method to compress my images with the help of following code:
ByteArrayOutputStream baos;
Bitmap img = BitmapFactory.decodeFile(imgs[i].getAbsolutePath());
img.compress(Bitmap.CompressFormat.JPEG, compFactor, baos);
byte[] compImgBytes;
compImgBytes = baos.toByteArray();
OutputStream out1 = new BufferedOutputStream(new FileOutputStream(
new File(dir.getString("dir", null) + File.separator +
String.valueOf(imgsName) + ".jpg")));
out1.write(compImgBytes);
Problem is, when I use 100 as a compression factor (compFactor = 100
) for this code, the size of the resultant image is larger than the image being compressed. All I was trying to do was compress the image with max quality as per Android documentation for the Bitmap class.
Why is the resultant image's size greater than original image's size? Am I missing something?