OutofMemoryError:位图大小超过VM预算(Android) [英] OutofMemoryError: bitmap size exceeds VM budget (Android)
问题描述
ERROR / AndroidRuntime(7906):java.lang.OutOfMemoryError:位图大小超过VM预算
错误/ AndroidRuntime(7906):在android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:295)
我的代码很简单。我用默认图像定义了一个XML布局。我试图在SDCard上加载一个bm(如果存在的话)。如果没有显示默认图像。这里是代码:
public class showpicture extends Activity {
public void onCreate(Bundle savedInstanceState){
/ **删除菜单/状态栏** /
requestWindowFeature(Window.FEATURE_NO_TITLE);
final Window win = getWindow();
win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Bitmap bm;
super.onCreate(savedInstanceState);
setContentView(R.layout.showpicture);
try {
ImageView mImageButton =(ImageView)findViewById(R.id.displayPicture);
bm = Bitmap.createScaledBitmap(BitmapFactory.decodeFile(/ sdcard / dcim / Camera / 20091018203339743.jpg),100,100,true);
parkImageButton.setImageBitmap(bm);
}
catch(IllegalArgumentException ex){
Log.d(MYAPP,ex.getMessage());
}
catch(IllegalStateException ex){
在code> bm = Bitmap.createScaledBitmap 任何想法?我在论坛上做了一些研究,并指出这篇文章
我只是不知道为什么它不工作。任何帮助将是伟大的!谢谢,
Chris。
http://mobi-solutions.blogspot.com/2010/08/how-to-if-you-want-to-create-and.html
Getting an Exception in the BitmapFactory. Not sure what is the issue. (Well I can guess the issue, but not sure why its happening)
ERROR/AndroidRuntime(7906): java.lang.OutOfMemoryError: bitmap size exceeds VM budget ERROR/AndroidRuntime(7906): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:295)
My code is pretty straight forward. I defined an XML layout w/ a default image. I try to load a bm on the SDCard (if present - it is). If not it shows the default image. Anyway.. Here is code :
public class showpicture extends Activity {
public void onCreate(Bundle savedInstanceState) {
/** Remove menu/status bar **/
requestWindowFeature(Window.FEATURE_NO_TITLE);
final Window win = getWindow();
win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Bitmap bm;
super.onCreate(savedInstanceState);
setContentView(R.layout.showpicture);
try {
ImageView mImageButton = (ImageView)findViewById(R.id.displayPicture);
bm = Bitmap.createScaledBitmap(BitmapFactory.decodeFile("/sdcard/dcim/Camera/20091018203339743.jpg"),100, 100, true);
parkImageButton.setImageBitmap(bm);
}
catch (IllegalArgumentException ex) {
Log.d("MYAPP",ex.getMessage());
}
catch (IllegalStateException ex) {
It fails on the bm=Bitmap.createScaledBitmap
any thoughts? I did some research on the forums, and it pointed to this post
I just don't know why it is not working. Any help would be great! Thanks,
Chris.
http://code.google.com/p/android/issues/detail?id=8488
http://mobi-solutions.blogspot.com/2010/08/how-to-if-you-want-to-create-and.html
这篇关于OutofMemoryError:位图大小超过VM预算(Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!