Hello,
I want to know how I can export my map ? Like the function GetBitmap() in the Web Edition.
I want to create an image of my map like I see it with all the layers.
Thanks in advance.
Pierre-Antoine
Hello,
I want to know how I can export my map ? Like the function GetBitmap() in the Web Edition.
I want to create an image of my map like I see it with all the layers.
Thanks in advance.
Pierre-Antoine
I found how to do it :
Bitmap image = new Bitmap(winformsMap1.ClientSize.Width, winformsMap1.ClientSize.Height);
winformsMap1.DrawToBitmap(image, winformsMap1.ClientRectangle);
image.Save(@"c:\test.bmp");
I am glad you figured it out. To extent on that idea, you can use the graphics object of the image to draw an outline, drw some text for the title of the map etc. The code below was written very rapidly but you see how you could draw your own legend, title etc on the image using Graphics.
Bitmap image = new Bitmap(winformsMap1.Width + 40 , winformsMap1.Height + 50);
Graphics g = Graphics.FromImage(image);
g.DrawRectangle(new Pen(Color.Black), new Rectangle(2, 2, winformsMap1.Width + 36, winformsMap1.Height + 46));
g.DrawString("MY MAP", new Font("Arial", 12, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(250, 10));
winformsMap1.DrawToBitmap(image, new Rectangle(20,40, winformsMap1.Width, winformsMap1.Height));
image.Save(@"c:\temp\test.bmp");