【问题标题】:Put a Bitmap on a picture template and add as a Marker将位图放在图片模板上并添加为标记
【发布时间】:2016-09-06 01:27:02
【问题描述】:

现在,我从 URL 获取图片并将其存储为位图。我想要做的是拍摄照片并调整其大小,然后将其放在“模板”图片的顶部(如下所示,作为可绘制文件夹中的资源文件)并将其作为标记放置在 GoogleMap 上。

我读到您可以用图片创建画布,但我不确定如何将另一张图片放在另一张图片之上。

【问题讨论】:

标签: android google-maps bitmap


【解决方案1】:
private static Bitmap makeStackedBitmap(final Bitmap background, final Bitmap foreground)
{
    Bitmap result = Bitmap.createBitmap(background.getWidth(), background.getHeight(), background.getConfig());   //Initialize the result image
    Canvas canvas = new Canvas(result);   //Create a canvas so we can draw onto the result image
    canvas.drawBitmap(background, 0, 0, null);   //Draw the background
    canvas.drawBitmap(foreground, 0, 0, null);   //Draw the foreground. Change (0, 0) if you want.
    return result;   //Returns single image with the background and foreground
}

【讨论】:

    【解决方案2】:

    通常,位图图像不需要调整大小来添加标记。标记在地图上具有默认大小。使用保存的位图图像作为标记图像。

    googleMap.addMarker(new MarkerOptions()
                .position(your_latLng)
                .draggable(your_choice)
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.your_saved_image/bitmap)));
    

    【讨论】:

    • "然后将其放在'模板'图片的顶部(如下所示,作为可绘制文件夹中的资源文件)"
    猜你喜欢
    • 2013-10-14
    • 2020-05-07
    • 1970-01-01
    • 2020-07-03
    • 2014-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-15
    相关资源
    最近更新 更多