GeoTiff/PNG
コードで全体を処理するには大きすぎるファイルを使用しています。
bitmapfactory でファイルの特定の領域 (たとえば、2 つの x、y 座標で指定) をデコードする可能性はありますか? 似たようなものは見つかりませんでしたhttp://developer.android.com/reference/android/graphics/BitmapFactory.html
(Android の開発者リファレンス)。
ありがとう!
kcoppock のヒントで、次の解決策を設定しました。
なぜ代わりにrect
初期化する必要があるのか 疑問に思っていますが...Rect(left, bottom, right, top)
Rect(left, top, right, bottom)
呼び出しの例:
Bitmap myBitmap = loadBitmapRegion(context, R.drawable.heightmap,
0.08f, 0.32f, 0.13f, 0.27f);
関数:
public static Bitmap loadBitmapRegion(
Context context, int resourceID,
float regionLeft, float regionTop,
float regionRight, float regionBottom) {
// Get input stream for resource
InputStream is = context.getResources().openRawResource(resourceID);
// Set options
BitmapFactory.Options opt = new BitmapFactory.Options();
//opt.inPreferredConfig = Bitmap.Config.ARGB_8888; //standard
// Create decoder
BitmapRegionDecoder decoder = null;
try {
decoder = BitmapRegionDecoder.newInstance(is, false);
} catch (IOException e) {
e.printStackTrace();
}
// Get resource dimensions
int h = decoder.getHeight();
int w = decoder.getWidth();
// Set region to decode
Rect region = new Rect(
Math.round(regionLeft*w), Math.round(regionBottom*h),
Math.round(regionRight*w), Math.round(regionTop*h));
// Return bitmap
return decoder.decodeRegion(region, opt);
}