Drawing layer for rectangular zoom without redraw all layers (C#)

ApliesAplies Global Mapper UserPosts: 35Trusted User
edited March 2013 in SDK
Hello,

I have a problem concerning draw of layers.
I allow to user of my software to zoom on a rectangular area which he draws itself (with event Mouse down, mouse move and mouse up). But with the SDK, i must to redraw all layers when the user moves the mouse to do appear the area. I have lots of calculs and informations to display all my layers and the performances are very bad.
Have you a solution to redraw only one layer? I have tried to make several bitmap with transparence, but i can't display all these bitmap in one Winform (C#). I have tried lots of solutions but finally, SDK uses one bitmap for display all layers and i don't know if there is really a solution. (How do you implement that in your software Global Mapper?)

Thanks in advance.

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2013
    The GM_DrawLayerList function takes a list of layers to draw. You could draw all of your non-changing layers once to an offscreen bitmap and keep that around, then when you draw to the screen BitBlt that offscreen bitmap to your display window, then draw whatever else you need (like your map rectangle) on top of that. The trick is just the double-buffering so you just BitBlt the static data each draw and only redraw it when you actually zoom or pan.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.bluemarblegeo.com/
  • ApliesAplies Global Mapper User Posts: 35Trusted User
    edited March 2013
    Thanks for you reply very fast.

    I understand the principle (i believe). A little script to be sure :

    #Scenario#
    bitmap with static layer -> i put in the buffer of the bitmap the static layers -> |.....| <- (its the state of the buffer);
    ---- the user moves the mouse ---
    add temporary layer -> i put at the end of the buffer of the bitmap this layer -> |.....|..| <- (its the state of the buffer);
    ---- the user releases the mouse ---
    remove temporary layer of the buffer of the bitmap-> |.....| <- (its the state of the buffer);
    #End#

    But if the bitmap is modified, i must to redraw and refresh the background of the window with the bitmap no?
    And how can i remove just the part of the buffer what i need without destroy my bitmap? Maybe i must to recreate a bitmap each time?

    Sorry for all this questions but i'm a litlle confused to use buffer of bitmap.

    Thanks again.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2013
    If you have a dynamic layer that changes a lot I would create the one background bitmap with all of the static layers. Then when you draw BitBlt from that to your screen buffer, then draw your temporary layer (make sure to pass the flag not to erase the background). So long as your temporary layer draws fast that should be almost instantaneous.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.bluemarblegeo.com/
  • ApliesAplies Global Mapper User Posts: 35Trusted User
    edited March 2013
    Ok, thanks.

    But i wanted to find a solution to not reset bitmap with all static layers on my panel to not have a blinking effect, when the user draws an area with mouse on temporary layer at top.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2013
    To get rid of the blinking affect you may need an addition offscreen buffer. Render everything to that for a draw, then BitBlt that all at once to the screen. That should eliminate any blinking.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.bluemarblegeo.com/
Sign In or Register to comment.