Search code examples
androidimagethumbnailsandroid-galleryimage-compression

Android Gallery Thumbnail Images


I am developing an application which loads images from local device storage. I used compression technique code:

FileOutputStream fo = new FileOutputStream(file);
picture.compress(Bitmap.CompressFormat.JPEG, 90, fo);
fo.flush();
fo.close();

where picture is a bitmap. This shows a low quality unreadable image.

Is there any efficient compression technique. Also, how does android gallery show thumbnail images which are readable and of smaller file size?


Solution

  • Solved it using ThumbnailUtils:

       Bitmap picture = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(_path_to_your_file), FINAL_WIDTH, FINAL_HEIGHT);
    

    Image size is reduced much