以下是我想要的内容:在IndoorAtlas中加载平面布局并显示当前位置。 这里是我的代码:使用IndoorAtlas将位图显示到UI线程中
public void loadFloorPlanImage(FloorPlan floorPlan) {
BitmapFactory.Options options = createBitmapOptions(floorPlan);
FutureResult<Bitmap> result = mIndoorAtlas.fetchFloorPlanImage(floorPlan,options);
result.setCallback(new ResultCallback<Bitmap>() {
@Override
public void onResult(final Bitmap result) {
runOnUiThread(new Runnable() {
@Override
public void run() {
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageBitmap(result);
}
});
}
});
}
这:
private BitmapFactory.Options createBitmapOptions(FloorPlan floorPlan) {
int reqWidth = 2048;
int reqHeight = 2048;
final int width = (int) floorPlan.dimensions[0];
final int height = (int) floorPlan.dimensions[1];
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height/2;
final int halfWidth = width/2;
while ((halfHeight/inSampleSize) > reqHeight
&& (halfWidth/inSampleSize) > reqWidth) {
inSampleSize *= 2;
}
}
options.inSampleSize = inSampleSize;
return options;
}
我收到错误结果:
java.lang.NullPointerException: Attempt to write to field 'int android.graphics.BitmapFactory$Options.inSampleSize' on a null object reference
at skripsi.ubm.studenttracking.indoor.createBitmapOptions(indoor.java:370)
at skripsi.ubm.studenttracking.indoor.loadFloorPlanImage(indoor.java:322)
at skripsi.ubm.studenttracking.indoor$1.onResult(indoor.java:163)
at skripsi.ubm.studenttracking.indoor$1.onResult(indoor.java:159)
你能帮助我吗?
你忘了初始化内部createBitmapOptions方法选项。 – Manish