Sample for Raser layer creation

mrkrishnanmrkrishnan Global Mapper UserPosts: 29
edited June 2010 in SDK
Can anyone provide some simple example for how to create raster layer using GM_CreateRasterLayer.



  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited June 2010
    Here is some very basic sample code for setting up a custom raster layer from a 24-bit RGB in-memory data buffer of size 100 pixels by 64 pixels (just some random numbers that I picked):

    // Setup raster layer structure
    GM_RasterLayout_t theLayout;
    memset( &theLayout, 0, sizeof theLayout );
    theLayout.mXPixelSize = 1.0 / 3600.0; // set this to the actual size in the X direction of your pixels
    theLayout.mYPixelSize = 1.0 / 3600.0; // set this to the actual size in the Y direction of your pixels
    theLayout.mPixelWidth = 100;
    theLayout.mPixelHeight = 64;
    theLayout.mNumBands = 3;
    theLayout.mBitsPerBand = 8;

    // Setup a projection to use (Geographic/lat/lon in this case)
    GM_Projection_t theLayerProj;
    memset( &theLayerProj, 0, sizeof theLayerProj );
    theLayerProj.mProjSys = GM_PRJ_GEO;
    theLayerProj.mDatum = GM_DATUM_WGS_84;
    theLayerProj.mUnits = GM_PRJ_UNIT_ARC_DEGREES;

    // Create the raster layer (assume mDataBuf is the 24-bit RGB buffer of size 100 * 64 * 3)
    GM_LayerHandle_t32 theLayer = GM_CreateCustomRasterLayer
    "My Custom Raster Layer", &theLayerProj, &theLayout, theDataBuf

    Let me know if I can be of further assistance.


    Global Mapper Support
Sign In or Register to comment.