Printing / Saving GMap Control contents with markers.

Feb 1, 2009 at 10:24 AM
Edited Feb 1, 2009 at 10:58 AM

Superb control!  How do I save current contents of Gmap control to image file and print contents of Gmap control with markers?  Please help.

Coordinator
Feb 1, 2009 at 12:46 PM
yet there is no current view export function, but you can push print screent, and paste content anywhere you want... i'll keep this feature in mind
Feb 1, 2009 at 3:10 PM
Thanks.
Coordinator
Apr 10, 2009 at 4:57 AM
works on wpf
Jun 4, 2009 at 4:44 PM

Hello!

Any news about the implementation of this function in windows.form?

 

Thanks

Coordinator
Jun 4, 2009 at 6:53 PM

not so far ;/ ..but i have some idea...

Jun 18, 2009 at 11:05 AM
Edited Jun 18, 2009 at 11:08 AM

private void btnSaveImage_Click(object sender, EventArgs e)
{
    sfd.Filter = "JPeg (*.jpg)|*.jpg";
    if (sfd.ShowDialog() == DialogResult.OK)
    {
        System.Drawing.Point sp = MainMap.Location;
        System.Drawing.Size ds = MainMap.Size;
        System.Drawing.Rectangle sr = new System.Drawing.Rectangle(sp, ds);
        //Convert the Image to a JPG
        Image tmpImage;
        tmpImage = CaptureImage(sp, System.Drawing.Point.Empty, sr, "");
        tmpImage.Save(sfd.FileName);
     }
}

public Image CaptureImage(System.Drawing.Point SourcePoint, System.Drawing.Point DestinationPoint, System.Drawing.Rectangle SelectionRectangle, string FilePath)
{
     Image tmpImage;
     using (Bitmap bitmap = new Bitmap(SelectionRectangle.Width, SelectionRectangle.Height))
     {
           using (Graphics g = Graphics.FromImage(bitmap))
           {
                 g.CopyFromScreen(SourcePoint, DestinationPoint, SelectionRectangle.Size);
           }
           //Convert the Image to a JPG
           MemoryStream ms = new MemoryStream();
           bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
           tmpImage = Image.FromStream(ms);
           return tmpImage;
     }
}

 

 

Coordinator
Jun 18, 2009 at 12:19 PM

thanks!

Feb 12, 2010 at 12:41 PM

I'm working in WPF. Someone tried to save to EMF?

This is my procedure for the bitmaps:

private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            // there is no wmf encoder in .NET. See http://msdn.microsoft.com/en-us/library/bb882579.aspx
            // add a reference to the System.Drawing dll in your Visual Studio project
            // as there is are no handles in WPF, how to create a Metafile
            // Then save it using GetEnhMetaFileBits?

            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName = "Map";
            dlg.DefaultExt = ".png";
            dlg.Filter = "Portable Network Graphics (.png)|*.png|Joint Photographic Experts Group (.jpg)|*.jpg|Graphics Interchange Format (.gif)|*.gif|Windows Bitmap (.bmp)|*.bmp|Tagged Image File Format (.tif)|*.tif?";
            if (dlg.ShowDialog() == true)
            {
                RenderTargetBitmap bmp = new RenderTargetBitmap((int)MainMap.ActualWidth, (int)MainMap.ActualHeight, 96, 96, PixelFormats.Pbgra32);
                bmp.Render(MainMap);
                string Extension = System.IO.Path.GetExtension(dlg.FileName).ToLower();
                BitmapEncoder encoder;
                if (Extension == ".gif")
                    encoder = new GifBitmapEncoder();
                else if (Extension == ".png")
                    encoder = new PngBitmapEncoder();
                else if (Extension == ".jpg")
                    encoder = new JpegBitmapEncoder();
                else if (Extension == ".bmp")
                    encoder = new BmpBitmapEncoder();
                else if (Extension == ".tif")
                    encoder = new TiffBitmapEncoder();
                else return;

                encoder.Frames.Add(BitmapFrame.Create(bmp));
                using (Stream stm = File.Create(dlg.FileName))
                {
                    encoder.Save(stm);
                }
            }
        }