android - why Bitmap convert to byte[] will cause size increase? -


i have funtion compress bitmap below 32k. when got returned bitmap, converted byte[], size increased. code demo below, output :

before: 30
after: 85

did use bitmap in wrong way?

bytearrayoutputstream baos = new bytearrayoutputstream(); image.compress(bitmap.compressformat.jpeg, 100, baos); int options = 100; while (baos.tobytearray().length / 1024 > 31 && (count++ < 8)) { // compress below 32k     baos.reset();     options -= 10;     image.compress(bitmap.compressformat.jpeg, options, baos); }  bytearrayinputstream isbm = new bytearrayinputstream(baos.tobytearray()); bitmap bitmap = bitmapfactory.decodestream(isbm, null, null); ll.d("before: " + (baos.tobytearray().length/1024)); // here return bitmap; bytearrayoutputstream output = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.jpeg, 100, output); ll.d("after: " + (output.tobytearray().length/1024)); 


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -