gpt4 book ai didi

android - 如何调查在 Android 中使用 BitmapFactory 加载位图的问题? "getEntry failing because entryIndex..."

转载 作者:行者123 更新时间:2023-11-30 04:29:03 25 4
gpt4 key购买 nike

我正在尝试加载位图并将其显示在 Canvas 上。我以前用这种方法做过,效果很好。不幸的是,这次出了点问题,我不知道如何追查问题。

我的代码到达这里:

Log.d(TAG, "Loading bitmaps");
this.stageL=BitmapFactory.decodeResource(getResources(), R.drawable.stagel);
Log.d(TAG,"Bitmap loaded");
int stageLHeight = stageL.getHeight();
Log.d(TAG,String.valueOf(stageLHeight));

但随后我在 Loading bitmapsBitmap Loaded 之间的 logcat 中收到警告。之后应用程序强制关闭,我再也看不到 stageLHeight 的值。

这是日志:

11-07 15:22:50.182: DEBUG/LabSetup(613): Loading bitmaps
11-07 15:22:50.182: WARN/ResourceType(613): getEntry failing because entryIndex 3 is beyond type entryCount 1
11-07 15:22:50.182: WARN/ResourceType(613): Failure getting entry for 0x7f020003 (t=1 e=3) in package 0 (error -2147483647)
11-07 15:22:50.182: DEBUG/LabSetup(613): Bitmap loaded
11-07 15:22:50.222: WARN/dalvikvm(613): threadid=9: thread exiting with uncaught exception (group=0x40014760)
11-07 15:22:50.222: ERROR/AndroidRuntime(613): FATAL EXCEPTION: Thread-10
11-07 15:22:50.222: ERROR/AndroidRuntime(613): java.lang.NullPointerException
11-07 15:22:50.222: ERROR/AndroidRuntime(613): at com.cjs.duallaseralignment.LabSetup.SetCanvasSize(LabSetup.java:53)
11-07 15:22:50.222: ERROR/AndroidRuntime(613): at com.cjs.duallaseralignment.MainAppPanel.onDraw(MainAppPanel.java:136)
11-07 15:22:50.222: ERROR/AndroidRuntime(613): at com.cjs.duallaseralignment.MainThread.run(MainThread.java:56)

如果它有用,R.java:

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
public static final int mag=0x7f020001;
public static final int magr=0x7f020002;
public static final int stagel=0x7f020003;
public static final int stager=0x7f020004;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}

最佳答案

错误存在于您的 Logcat 中。

11-07 15:22:50.222: ERROR/AndroidRuntime(613): at com.cjs.duallaseralignment.LabSetup.SetCanvasSize(LabSetup.java:53)

如果您能指出第 53 行,将会有所帮助。

因为你没有得到告诉你图像大小的日志,所以我猜是

int stageLHeight = stageL.getHeight();

是第 53 行。我的下一个猜测是加载的图像为空。如果图像不存在,或者无法从资源文件解码图像,就会发生这种情况。

关于android - 如何调查在 Android 中使用 BitmapFactory 加载位图的问题? "getEntry failing because entryIndex...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8038689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com