0

Right now, I'm getting a picture from a URL and storing it as a bitmap. What I want to do, is take the picture and resize it then place it on top of a 'template' picture (something like below, to be a resource file in the drawable folder) and place it on a GoogleMap as a marker.

I read you can create a canvas out of a picture, I'm just not sure how I can place another picture on top of another.

template picture

Community
  • 1
  • 1
SaltySea
  • 700
  • 1
  • 7
  • 21

2 Answers2

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
}
Jason Leddy
  • 111
  • 6
0

Generally, the bitmap image does not need to resize to add on marker. Marker has a default size on Maps. Use the saved bitmap image as marker image.

googleMap.addMarker(new MarkerOptions()
            .position(your_latLng)
            .draggable(your_choice)
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.your_saved_image/bitmap)));
W4R10CK
  • 5,502
  • 2
  • 19
  • 30
  • "then place it on top of a 'template' picture (something like below, to be a resource file in the drawable folder)" – SaltySea Sep 10 '16 at 22:15