[英]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的特定問題。 您可以調整例如要生成的位圖圖像的大小,或者僅將選項保留為null。 查看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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.