This project is read-only.

Exporting/saving bitmap froma map

Dec 2, 2010 at 4:14 PM

Is possible having or exporting a bitmap form a map ?

I was trying something like this:

           Map m = new Map();

            m.ProjectionModeDefine = ActionMode.Never;

            m.Width = 200;
            m.Height = 200;

            m.AddLayer(@"C:\temp\comuni.shp");

            Bitmap b = new Bitmap(m.Width, m.Height);
            Rectangle r = new Rectangle(0, 0, m.Width - 1, m.Height - 1);

            m.DrawToBitmap(b, r);

            pictureBox1.Image = b;

            b.Save(@"C:\temp\xxx.jpg");

 

but it doesen't works !

 

Dec 2, 2010 at 7:21 PM

interesting.  maybe a bug.  try the print or draw methods on m.mapframe, or possibly a snapshot method.  we have lots of methods that could be used, but hopefully one of gthose will work for you.

Dec 16, 2010 at 1:17 PM

Map m = new Map();

m.ProjectionModeDefine = ActionMode.Never;

m.Width = 300;
m.Height = 300;

Rectangle r = new Rectangle(0, 0, m.Width, m.Height);

m.AddLayer(@"C:\temp\comuni.shp");

m.ZoomToMaxExtent();

Bitmap b = new Bitmap(m.Width, m.Height);
Graphics g = Graphics.FromImage(b);


m.MapFrame.Print(g, r);

string fname = @"C:\temp\temp.jpg";
b.Save(fname);

 

should work !