【发布时间】:2010-12-07 21:15:01
【问题描述】:
在 BitmapFactory 中获取异常。不确定是什么问题。 (嗯,我可以猜到这个问题,但不知道为什么会发生)
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) {
/** 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) {
bm=Bitmap.createScaledBitmap 失败有什么想法吗?我在论坛上做了一些研究,它指向this post
我只是不知道为什么它不起作用。任何帮助都会很棒!谢谢,
克里斯。
【问题讨论】:
-
原始JPG图片有多大?这里有一些关于这种错误的报告,有两个 6 Mpx 文件:groups.google.com/group/android-developers/browse_thread/thread/…
标签: android exception bitmap dalvik