可能重复: Bitmap太大而不能上传到纹理
我拍照用的相机,那么我保存照片的SD卡,然后用
I am taking a picture using the camera, then I am saving the picture on the sdcard, then using
位图BM = BitmapFactory.de codeFILE(路径);
要得到位图,然后
imageView.setImageBitmap(BM);
来设置它。
但是,当我把它放到我的看法使用
But when I put it into my view using
mFrameLayout.addView(ImageView的);
不显示图像,我回去位图到大被上传到质地
mFrameLayout.addView(imageView);
no image is displayed and I get back Bitmap to large to be uploaded into texture
的位图 1944年的高,2592宽
有什么想法?
我使用的是平板电脑10.1英寸宏碁Iconia,A500,运行集成电路。
I am using a tablet, 10.1 inches, acer iconia, a500, running ics.
尝试用这种
public static Bitmap decodeFile(File f,int WIDTH,int HIGHT){
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_WIDTH=WIDTH;
final int REQUIRED_HIGHT=HIGHT;
//Find the correct scale value. It should be the power of 2.
int scale=1;
while(o.outWidth/scale/2>=REQUIRED_WIDTH && o.outHeight/scale/2>=REQUIRED_HIGHT)
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;
}
这将扩大位图按照宽度和高度传递
this will scale bitmap as per width and height you pass