private void MenuItemExportJPEG_Click(object sender, EventArgs e) { try { SaveFileDialog exportJPGDialog = new SaveFileDialog(); exportJPGDialog.Title = "导出JPEG图像"; exportJPGDialog.Filter = "Jpeg Files(*.jpg,*.jpeg)|*.jpg,*.jpeg"; exportJPGDialog.RestoreDirectory = true; exportJPGDialog.ValidateNames = true; exportJPGDialog.OverwritePrompt = true; exportJPGDialog.DefaultExt = "jpg"; if (exportJPGDialog.ShowDialog() == DialogResult.OK) { double lScreenResolution; lScreenResolution = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.Resolution; IExport pExporter = new ExportJPEGClass() as IExport; //IExport pExporter = new ExportPDFClass() as IExport;//直接可以用!! pExporter.ExportFileName = exportJPGDialog.FileName; pExporter.Resolution = lScreenResolution; tagRECT deviceRECT; //用这句的话执行到底下的output()时就会出现错误:Not enough memory to create requested bitmap //MainaxMapControl.ActiveView.ScreenDisplay.DisplayTransformation.set_DeviceFrame(ref deviceRECT); deviceRECT = axMapControl1.ActiveView.ExportFrame; IEnvelope pDriverBounds = new EnvelopeClass(); //pDriverBounds = MainaxMapControl.ActiveView.FullExtent; pDriverBounds.PutCoords(deviceRECT.left, deviceRECT.bottom, deviceRECT.right, deviceRECT.top); pExporter.PixelBounds = pDriverBounds; ITrackCancel pCancel = new CancelTrackerClass(); axMapControl1.ActiveView.Output(pExporter.StartExporting(), (int)lScreenResolution, ref deviceRECT, axMapControl1.ActiveView.Extent, pCancel); pExporter.FinishExporting(); pExporter.Cleanup(); MessageBox.Show("导出Jpeg图像成功!图像保存在" + exportJPGDialog.FileName, "保存成功", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }
ArcGIS Engine 导出图片格式(代码示例)
猜你喜欢
转载自blog.csdn.net/weixin_40184249/article/details/80506130
今日推荐
周排行