Android 图库缩略图

Android Gallery Thumbnail Images

我正在开发一个从本地设备存储加载图像的应用程序。 我使用压缩技术代码:

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

其中图片是位图。 这显示了低质量的不可读图像。

有没有什么高效的压缩技术。 另外,android 图库如何显示可读且文件大小较小的缩略图?

希望对您有所帮助

Picasso.with(context)
            .load(imageUri) // will come from gallery
            .resize(imageWidth, imageWidth).centerInside()
            .into(imageview);

我做到了

    public static final int GRID_PADDING = 8; // in dp
    public static final int NUM_OF_COLUMNS  = 3; 
    Resources r = getResources();
        float padding =   TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,GRID_PADDING,r.getDisplayMetrics());
imageWidth = (int) ((getScreenWidth()) - ((NUM_OF_COLUMNS + 1) * padding)) /   NUM_OF_COLUMNS);

使用 ThumbnailUtils 解决了它:

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

图像尺寸减小了很多