android中显示图像拇指的最佳方法是什么?

时间:2012-12-31 12:24:29

标签: bitmap imageview

我创建了一个应用程序,我从互联网上下载图像并在活动中逐页显示。

用户要求是在活动底部显示每个图像缩略图。

所以我使用此代码创建了拇指。

/**
     * Method for decode Sampled Bitmap From Resource for thumb image.
     * 
     * @param fileName
     * @param reqWidth
     * @param reqHeight
     * @return Bitmap
     */
    public Bitmap decodeSampledBitmapFromResource(String fileName,int reqWidth, int reqHeight) 
    {

        String imagePath = fileName;        

        @SuppressWarnings("unused")
        File imgFile = new File(imagePath);

        // First decode with inJustDecodeBounds=true to check dimensions
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(imagePath,options);

        // Calculate inSampleSize
        options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

        // Decode bitmap with inSampleSize set
        options.inJustDecodeBounds = false;
        generalHelperbitmap = BitmapFactory.decodeFile(imagePath,options);


        return generalHelperbitmap;
    }

但我的问题是;这是显示拇指的最好方法吗?

是否有另一种方法可以下载主图像并使用新的小宽度和新的小高度显示这些页面?

在这个问题中,我从互联网上下载图像并解码到位图并逐页显示该图像。

有人可以告诉我哪一个是显示图片和拇指的最佳方式?

当我下载大于50的图像列表时,应用程序的性能会很慢,当我更改设备方向时,应用程序的性能会更慢。

感谢任何帮助!

0 个答案:

没有答案
相关问题