Java Android Eclipse - Resize/Scale 来自目录存储的图像

Java Android Eclipse - Resize/Scale image from directory storage

我有这样的字符串

String path = "storage/sdcard0/Pictures/location/img.jpg";

该字符串是文件 img.jpg 的位置。我怎么能 scale/resize 那张图片。 谢谢..

/*
 * Resizing image size
 */
public static Bitmap decodeFile(String filePath, int WIDTH, int HIGHT) {
    try {

        File f = new File(filePath);

        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(new FileInputStream(f), null, o);

        final int REQUIRED_WIDTH = WIDTH;
        final int REQUIRED_HIGHT = HIGHT;
        int scale = 1;
        while (o.outWidth / scale / 2 >= REQUIRED_WIDTH
                && o.outHeight / scale / 2 >= REQUIRED_HIGHT)
            scale *= 2;

        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize = scale;
        return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return null;

}

   Bitmap image = decodeFile(_filePaths.get(position), imageWidth, imageHeight);

    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setLayoutParams(new GridView.LayoutParams(imageWidth,
            imageWidth));
   imageView.setImageBitmap(image);