软件GIS系统采用了mapx5.0控件,现在利用mapx控件自己带的保存图片的方法,代码如下:
public void SaveTheMap(string SavePath, string Format, int Width, int Height)
{
this._Map.PaperUnit = PaperUnitConstants.miPaperUnitCentimeter;
this._Map.ExportMap("CLIPBOARD", MapXLib.ExportFormatConstants.miFormatBMP, Width, Height);
//运行完上面一句话就直接跳到下面粘的第二段代码中
Image im = System.Windows.Forms.Clipboard.GetImage();
if (Format == "JPG")
im.Save(SavePath, System.Drawing.Imaging.ImageFormat.Jpeg);
else if (Format == "BMP")
im.Save(SavePath, System.Drawing.Imaging.ImageFormat.Bmp);
System.Windows.Forms.Clipboard.Clear();
}
下面是第二段代码,这段代码是主窗体的Designer.cs 里面的
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
很奇怪软件也不报错,运行完那句之后直接就去dispose 了,不知道为什么,大家有没有碰到类似的情况 ,求大虾指点~~
public void SaveTheMap(string SavePath, string Format, int Width, int Height)
{
this._Map.PaperUnit = PaperUnitConstants.miPaperUnitCentimeter;
this._Map.ExportMap("CLIPBOARD", MapXLib.ExportFormatConstants.miFormatBMP, Width, Height);
//运行完上面一句话就直接跳到下面粘的第二段代码中
Image im = System.Windows.Forms.Clipboard.GetImage();
if (Format == "JPG")
im.Save(SavePath, System.Drawing.Imaging.ImageFormat.Jpeg);
else if (Format == "BMP")
im.Save(SavePath, System.Drawing.Imaging.ImageFormat.Bmp);
System.Windows.Forms.Clipboard.Clear();
}
下面是第二段代码,这段代码是主窗体的Designer.cs 里面的
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
很奇怪软件也不报错,运行完那句之后直接就去dispose 了,不知道为什么,大家有没有碰到类似的情况 ,求大虾指点~~
解决方案 »
- 如何添加C# 外部控件!
- 求winform好用的编辑器
- 急求!怎样递归填充树啊?
- 用File.Copy覆盖原来存在的文件,文件名不就,文件的创建时间会不会改变啊?
- 最近学习C#感觉他就象浩瀚的海洋
- 请教C#中代码动态编译Microsoft.CSharp.Compiler.Compile(...)出错的问题
- 欢迎加入QQ群:5030333(.NET J2EE 编程思想与架构设计)
- Webclient的下载问题,IE可以看,但是不能下载
- C#连access接数据库,指定记录的密码无法获取,程序如下,请大神们帮忙啊
- 为什么打不开数据库?
- winform,datagridview中选定行的数据转移到另一个窗体的datagridview
- 在IIS 6.0中httpmodules无法接管html请求,请问怎么回事?
public virtual void ExportMap(string destination, ExportFormatConstants format, object width, object height);
看不到里面的代码,但是我上面粘出来的第一段代码,我在其它的地方也有用到,运行时就直接到下一句话了
public void createTempPic()
{
//保存图例
string FolderPath = Application.StartupPath + "\\Pictures\\";
saveLengend(Thresholds._VoltRangeString, Thresholds._VoltColors, "volt");
saveLengend(Thresholds._BERRangeString, Thresholds._BERColors, "ber");
saveLengend(Thresholds._MERRangeString, Thresholds._MERColors, "mer");
saveLengend(Thresholds._LDPCRangeString, Thresholds._LDPCColors, "ldpc");
saveLengend(Thresholds._SNRRangeString, Thresholds._SNRColors, "snr");
saveLengend(Thresholds._RSRangeString, Thresholds._RSBLERColors, "rs");
////保存路测图
this.selectedSection.Map.Map.Layers._Item("StrLayer").Visible = true;
this.selectedSection.Map.Map.Layers._Item("SnrLayer").Visible = false;
this.selectedSection.Map.Map.Layers._Item("BerLayer").Visible = false;
this.selectedSection.Map.Map.Layers._Item("MerLayer").Visible = false;
this.selectedSection.Map.Map.Layers._Item("RsLayer").Visible = false;
this.selectedSection.Map.Map.Layers._Item("LdpcLayer").Visible = false;
savePic("StrCover", "volt");然后再进入下面这个:
public void savePic(string picName, string type)
{
string Format;
Format = "JPG";
string s = Application.StartupPath + "\\Pictures\\" + picName + "." + Format;
int w, h;
if (selectedSection.Map.Map.Width > selectedSection.Map.Map.Height)
{
w = 65;
h = 70 * selectedSection.Map.Map.Height / selectedSection.Map.Map.Width;
}
else
{ h = 65;
w = 70 * selectedSection.Map.Map.Width / selectedSection.Map.Map.Height; }
//就是下面这句
selectedSection.Map.SaveTheMap(s, Format, w, h);
System.Drawing.Bitmap bmp = new Bitmap(s);
System.Drawing.Image volt;
Graphics g = Graphics.FromImage(bmp);
volt = new Bitmap(Application.StartupPath + "\\Pictures\\" + type + ".bmp");
g.DrawImage(volt, 0, 0); bmp.Save(Application.StartupPath + "\\Pictures\\" + type + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
volt.Dispose();
bmp.Dispose();
g.Dispose();
File.Delete(s);
}