您的位置:首页 > 编程语言 > C#

AE+C# 导出图片(BMP、JPEG、GIF、PNG、TIFF)

2014-05-29 17:53 127 查看
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using ESRI.ArcGIS.Carto;

using ESRI.ArcGIS.Output;

using ESRI.ArcGIS.Geometry;

using ESRI.ArcGIS.esriSystem;

using ESRI.ArcGIS.Controls;

namespace LeakOil.Export

{

public partial class ExportMapForm : Form

{

AxMapControl m_Map;

public ExportMapForm(AxMapControl mmap)

{

InitializeComponent();

m_Map = mmap;

}

private void buttonNO_Click(object sender, EventArgs e)

{

this.Close();

}

private void buttonSave_Click(object sender, EventArgs e)

{

SaveFileDialog SaveFile = new SaveFileDialog();

switch (comboBoxtype.SelectedIndex)

{

case 0:

SaveFile.Filter = "bmp文件(*.bmp)|*.bmp";

SaveFile.Title = "保存bmb文件";

break;

case 1:

SaveFile.Filter = "emf文件(*.emf)|*.emf";

SaveFile.Title = "保存jpeg文件";

break;

case 2:

SaveFile.Filter = "gif文件(*.gif)|*.gif";

SaveFile.Title = "保存gif文件";

break;

case 3:

SaveFile.Filter = "png文件(*.jpeg)|*.jpeg";

SaveFile.Title = "保存png文件";

break;

case 4:

SaveFile.Filter = "PNG文件(*.png)|*.png";

SaveFile.Title = "保存bmb文件";

break;

case 5:

SaveFile.Filter = "TIFF文件(*.TIFF)|*.TIFF";

SaveFile.Title = "保存tiff文件";

break;

}

if (SaveFile.ShowDialog() == DialogResult.OK)

{

textBoxPath.Text = SaveFile.FileName;

}

}

private void buttonOK_Click(object sender, EventArgs e)

{

IExport pExport;

switch (comboBoxtype.SelectedIndex)

{

case 0:

pExport = new ExportBMPClass();

Export(pExport);

break;

case 1:

pExport = new ExportEMFClass();

Export(pExport);

break;

case 2:

pExport = new ExportGIFClass();

Export(pExport);

break;

case 3:

pExport = new ExportJPEGClass();

Export(pExport);

break;

case 4:

pExport = new ExportPNGClass();

Export(pExport);

break;

case 5:

pExport = new ExportTIFFClass();

Export(pExport);

break;

}

}

public void Export(IExport pExport)

{

IActiveView pActiveView;

IEnvelope pPixelBoundsEnv;

int iOutputResolution;

int iScreenResolution;

int hdc;

pActiveView = m_Map.ActiveView;

pExport.ExportFileName = textBoxPath.Text.ToString();

iScreenResolution = 96;

iOutputResolution = 300;

pExport.Resolution = iOutputResolution;

tagRECT pExportFrame;

pExportFrame = pActiveView.ExportFrame;

tagRECT exportRECT;

exportRECT.left = 0;

exportRECT.top = 0;

exportRECT.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution);

exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution);

pPixelBoundsEnv = new EnvelopeClass();

pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);

pExport.PixelBounds = pPixelBoundsEnv;

hdc = pExport.StartExporting();

pActiveView.Output(hdc, (int)pExport.Resolution, ref exportRECT, null, null);

pExport.FinishExporting();

pExport.Cleanup();

}

private void ExportMapForm_Load(object sender, EventArgs e)

{

comboBoxtype.SelectedIndex = 0;

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: