Set Layer Transparency from script

superstefansuperstefan Global Mapper UserPosts: 30Trusted User
How can I define the background color of a raster layer, which should not be displayed? Basically the same functionality provided in the
CC->Options->Display->Tranparency->Set Transparent Color.
Thanky ou very much in advance.
Stefan

Answers

  • bmg_bobbmg_bob Global Mapper Programmer Posts: 1,688
    Hello,

    On your IMPORT command, use the TRANSPARENT_COLOR parameter as indicated below:

    TRANSPARENT_COLOR (elevation and raster only) - specifies the color to make transparent when rendering this overlay. The color should be specified as RGB(<red>,<green>,<blue>). For example, to make white the transparent color, use TRANSPARENT_COLOR=RGB(255,255,255). If you do not wish any color to be transparent, do not use this parameter. Optionally, if the image that you are making transparent uses a palette for the colors, you can specify a palette index in the following format: INDEX(<0-based palette index>). For example, to make the second color in the palette transparent, use TRANSPARENT_COLOR=INDEX(1).

    An easy way to do this is to load your layer in the main UI and set the transparency, then create a workspace.  When you open the workspace file you created in a text editor, you will see that it contains an IMPORT command that can be used to recreate the UI settings.

    Cheers,
    Bob

Sign In or Register to comment.