我尝试使用:为什么我不能调用具有错误类型参数的方法?
//decodes image and scales it to reduce memory consumption
private Bitmap decodeFile(File f)
{
try {
//Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f),null,o);
//The new size we want to scale to
final int REQUIRED_SIZE=70;
//Find the correct scale value. It should be the power of 2.
int scale=1;
while(o.outWidth/scale/2>=REQUIRED_SIZE && o.outHeight/scale/2>=REQUIRED_SIZE)
scale*=2;
//Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize=scale;
return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
} catch (FileNotFoundException e) {}
return null;
}
然后
R.drawable.image = decodeFile(R.drawable.image);
如何使用这种方法吗? R.drawable.image是整数,所以它给了我错误,我怎么能解码文件?我添加240kb的图像到textview。
如何从可绘制文件夹中获取文件? –
@hey:我不知道,没有Android的经验 - 但我怀疑如果你可以编辑你的问题来提供更多的上下文,它会帮助别人来帮助你。 –