How can i take/merge screen shot of Google map v2 and layout of xml both programmatically?

前端 未结 2 572
夕颜
夕颜 2020-12-05 05:47

I am taking screenshot of Google Map v2 by using code of this answer which is giving me output :

2条回答
  •  心在旅途
    2020-12-05 06:42

    I don't know Android API, but since you requested "alternate" methods I'll suggest using ImageMagick. On that site there are several binaries, thus I hope you can download one that suits your system. Otherwise you can download the sources (google around and you'll find many links about building it for Android).

    Since I work on a Windows machine I can only tell you how you can invoke it from Windows command-line, but the syntax is similar for other platforms. This app has also a vast selection of APIs for different languages (Java, C or C++ may be of interest for you in particular), so that you can use ImageMagick embedded in your application instead of invoking it from the command line.

    Now for the problem at hand: the operation you need to do is to put the "overlay sheet" with symbols over your map, like you'd do with a transparent sheet with drawings over a real map.

    So let's call map.png and overlay.png the two files to be merged. Note that also the overlay file is a PNG file (more on this later). Then you can obtain something close to what you desire with the following command-line invocation:

    composite.exe -compose atop overlay.png map.png output.jpg
    

    Why must the overlay also be a PNG image? That's because we need an "overlay sheet" that is transparent in most areas (except where you have the balloon tip and the other drawings), but JPG images don't store the transparency information (they don't have the alpha-channel, which stores this information).

    So you should modify the part of your code that generates the overlay so as to generate a PNG image with an appropriate alpha channel.

    Hope all this helps.

提交回复
热议问题