アプリケーションに(地図の)画像を入れて、その上にプログラムでいくつかのレイヤー(プレースホルダー、パスなど)を追加したいのですが、フォトショップのようなレイヤーアプローチが役立つと思いますが、私はどこから始めればいいのかわからない。チュートリアルまたはドキュメントへの簡単な例/リンクが役立ちます:)
ありがとう
アプリケーションに(地図の)画像を入れて、その上にプログラムでいくつかのレイヤー(プレースホルダー、パスなど)を追加したいのですが、フォトショップのようなレイヤーアプローチが役立つと思いますが、私はどこから始めればいいのかわからない。チュートリアルまたはドキュメントへの簡単な例/リンクが役立ちます:)
ありがとう
私はあなたが構築できる簡単なアプローチをあなたに与えています:
finalBitmap
。これは、すべてのレイヤー構成の最終的な宛先になります。Canvas
に描画するを作成しますfinalBitmap
。このキャンバスは、すべてのレイヤーを最終的なビットマップに描画するために使用されます。Bitmap
マップ画像を使用してを作成します。finalBitmap
キャンバスを使用して描画します。これはレイヤー1になります。例のコード:
//The empty Bitmap
finalBitmap = Bitmap.createBitmap(width, height , Bitmap.Config.ARGB_8888);
canvas = new Canvas(finalBitmap );
imageView.setImageBitmap(finalBitmap );
//Create the map image bitmap
Config config = Config.RGB_565;
Options options = new Options();
options.inPreferredConfig = config;
InputStream in = null;
Bitmap bitmap = null;
try {
in = new FileInputStream(fMapImage);
bitmap = BitmapFactory.decodeStream(in);
if (bitmap == null)
throw new RuntimeException("Couldn't load bitmap from asset :" + fMapImage.getAbsolutePath());
} catch (IOException e) {
throw new RuntimeException("Couldn't load bitmap from asset :" + fMapImage.getAbsolutePath());
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
}
}
}
//Draw the map image bitmap
Rect dst = new Rect(pt00.x, pt00.y, ptMM.x, ptMM.y);
canvas.drawBitmap(bitmap, null, dst, null);
//Here draw whatever else you want (markers, routes, etc.)
よろしく