I'm making a strategy game in C# (nothing too wild, no animations or action). I managed to draw a section of the map and allow the user to scroll it, using DrawImage and specify a region of the map image to draw:
RectangleF srcRect = new RectangleF(currentMapX, currentMapY, 500, 500);
mapSectionGraphics.DrawImage(mapImage, 0, 0, srcRect, GraphicsUnit.Pixel);
Now, when I scroll the map it works fine, but when I draw additional images onto the map, they flicker when scrolling.
Ideally, I guess, I would draw the entire map with all objects on it into one PictureBox, and
then take a section from that compound image to draw in the map navigation screen. This eliminates flickering as the map does not need to constantly build back up while scrolling.
My question is... how do I do this? I'm still learning the ropes in C#, so I hope something like this can be done in a not too complicated way. Thanks!
What I have tried:
As far as I can see I can only use DrawImage to draw actual "Image" resources of PictureBoxes, and not the actual result of several drawing operations.
I did find a piece of code that allows copying the result and drawing it into another PictureBox, and that worked well, but for this the source (in my case the full map) needs to be visible on the screen as well, which I don't want.