使用 IndoorAtlas 创建位图选项

Create Bitmap Options Using IndoorAtlas

我有以下代码:

void loadFloorPlanImage(FloorPlan floorPlan) {
BitmapFactory.Options options = createBitmapOptions(floorPlan);
FutureResult<Bitmap> result = ia.fetchFloorPlanImage(floorPlan, options);
result.setCallback(new ResultCallback<Bitmap>() {
        @Override
        public void onResult(final Bitmap result) {
           // now you have floor plan bitmap, do something with it
           updateImageViewInUiThread(result);
        }
        // handle error conditions
}
}

我感到困惑的是:

BitmapFactory.Options 选项 = createBitmapOptions(floorPlan);

我在 'createBitmapOptions' 应该做什么?

这不是 IndoorAtlas 的特定问题。您可以调整例如要生成的位图图像的大小,或者简单地将选项保留为空。看看http://developer.android.com/reference/android/graphics/BitmapFactory.html

如果您想限制要在应用的地图视图中使用的图像的最大尺寸,示例可能如下所示:

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;

        // Calculate the largest inSampleSize value that is a power of 2 and keeps both
        // height and width larger than the requested height and width.
        while ((halfHeight / inSampleSize) > reqHeight
                && (halfWidth / inSampleSize) > reqWidth) {
            inSampleSize *= 2;
        }

    }

    options.inSampleSize = inSampleSize;
    return options;

}