本文整理汇总了C#中IActiveView.Output方法的典型用法代码示例。如果您正苦于以下问题:C# IActiveView.Output方法的具体用法?C# IActiveView.Output怎么用?C# IActiveView.Output使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IActiveView
的用法示例。
在下文中一共展示了IActiveView.Output方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportMap
/// <summary>
/// 保存当前ActiveView为图片
/// </summary>
/// <param name="SaveFilePath">图片路径</param>
/// <param name="ActiveView">Map ActiveView</param>
public static void ExportMap(string SaveFilePath,IActiveView ActiveView)
{
IExport export = ExportBase(SaveFilePath);
double IScreenResolution = ActiveView.ScreenDisplay.DisplayTransformation.Resolution;
export.ExportFileName = SaveFilePath;
export.Resolution = IScreenResolution;
ESRI.ArcGIS.esriSystem.tagRECT deviceRECT = ActiveView.ExportFrame;
IEnvelope envelope = new EnvelopeClass();
deviceRECT.right = deviceRECT.right * 10;
deviceRECT.bottom = deviceRECT.bottom * 10;
envelope.PutCoords(deviceRECT.left, deviceRECT.top, deviceRECT.right, deviceRECT.bottom);
export.PixelBounds = envelope;
ITrackCancel Cancel=new ESRI.ArcGIS.Display.CancelTrackerClass();
ActiveView.Output(export.StartExporting(), (int)IScreenResolution*10, ref deviceRECT, ActiveView.Extent, Cancel);
export.FinishExporting();
export.Cleanup();
//MessageBox.Show("OK");
}
示例2: ExportImage
//输出当前地图为图片
public static string ExportImage(IActiveView pActiveView)
{
if (pActiveView == null)
{
return null;
}
try
{
SaveFileDialog pSaveFileDialog = new SaveFileDialog();
pSaveFileDialog.Filter = "JPEG(*.jpg)|*.jpg|AI(*.ai)|*.ai|BMP(*.BMP)|*.bmp|EMF(*.emf)|*.emf|GIF(*.gif)|*.gif|PDF(*.pdf)|*.pdf|PNG(*.png)|*.png|EPS(*.eps)|*.eps|SVG(*.svg)|*.svg|TIFF(*.tif)|*.tif";
pSaveFileDialog.Title = "输出地图";
pSaveFileDialog.RestoreDirectory = true;
pSaveFileDialog.FilterIndex = 1;
if (pSaveFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
{
return null;
}
string FileName = pSaveFileDialog.FileName;
IExport pExporter = null;
switch (pSaveFileDialog.FilterIndex)
{
case 1:
pExporter = new ExportJPEGClass();
break;
case 2:
pExporter = new ExportBMPClass();
break;
case 3:
pExporter = new ExportEMFClass();
break;
case 4:
pExporter = new ExportGIFClass();
break;
case 5:
pExporter = new ExportAIClass();
break;
case 6:
pExporter = new ExportPDFClass();
break;
case 7:
pExporter = new ExportPNGClass();
break;
case 8:
pExporter = new ExportPSClass();
break;
case 9:
pExporter = new ExportSVGClass();
break;
case 10:
pExporter = new ExportTIFFClass();
break;
default:
MessageBox.Show("输出格式错误");
return null;
}
IEnvelope pEnvelope = new EnvelopeClass();
ITrackCancel pTrackCancel = new CancelTrackerClass();
tagRECT ptagRECT;
ptagRECT = pActiveView.ScreenDisplay.DisplayTransformation.get_DeviceFrame();
int pResolution = (int)(pActiveView.ScreenDisplay.DisplayTransformation.Resolution);
pEnvelope.PutCoords(ptagRECT.left, ptagRECT.bottom, ptagRECT.right, ptagRECT.top);
pExporter.Resolution = pResolution;
pExporter.ExportFileName = FileName;
pExporter.PixelBounds = pEnvelope;
pActiveView.Output(pExporter.StartExporting(), pResolution, ref ptagRECT, pActiveView.Extent, pTrackCancel);
pExporter.FinishExporting();
//释放资源
pSaveFileDialog.Dispose();
System.Runtime.InteropServices.Marshal.ReleaseComObject(pExporter);
return FileName;
}
catch
{
return null;
}
}
示例3: ExportActiveView
//输出当前地图至指定的文件
public static void ExportActiveView(IActiveView pView, Size outRect, string outPath)
{
try
{
//参数检查
if (pView == null)
{
throw new Exception("输入参数错误,无法生成图片文件!");
}
//根据给定的文件扩展名,来决定生成不同类型的对象
ESRI.ArcGIS.Output.IExport export = null;
if (outPath.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase))
{
export = new ESRI.ArcGIS.Output.ExportJPEGClass();
}
else if (outPath.EndsWith(".tiff", StringComparison.OrdinalIgnoreCase))
{
export = new ESRI.ArcGIS.Output.ExportTIFFClass();
}
else if (outPath.EndsWith(".bmp", StringComparison.OrdinalIgnoreCase))
{
export = new ESRI.ArcGIS.Output.ExportBMPClass();
}
else if (outPath.EndsWith(".emf", StringComparison.OrdinalIgnoreCase))
{
export = new ESRI.ArcGIS.Output.ExportEMFClass();
}
else if (outPath.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
{
export = new ESRI.ArcGIS.Output.ExportPNGClass();
}
else if (outPath.EndsWith(".gif", StringComparison.OrdinalIgnoreCase))
{
export = new ESRI.ArcGIS.Output.ExportGIFClass();
}
SetOutputQuality(pView, 1);
export.ExportFileName = outPath;
IEnvelope pEnvelope = pView.Extent;
//导出参数
export.Resolution = 300;
tagRECT exportRect = new tagRECT();
exportRect.left = exportRect.top = 0;
exportRect.right = outRect.Width;
exportRect.bottom = (int)(exportRect.right * pEnvelope.Height / pEnvelope.Width);
ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
//输出范围
envelope.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom);
export.PixelBounds = envelope;
//可用于取消操作
ITrackCancel pCancel = new CancelTrackerClass();
export.TrackCancel = pCancel;
pCancel.Reset();
//点击ESC键时,中止转出
pCancel.CancelOnKeyPress = true;
pCancel.CancelOnClick = false;
pCancel.ProcessMessages = true;
//获取handle
System.Int32 hDC = export.StartExporting();
//开始转出
pView.Output(hDC, (System.Int32)export.Resolution, ref exportRect, pEnvelope, pCancel);
bool bContinue = pCancel.Continue();
//捕获是否继续
if (bContinue)
{
export.FinishExporting();
export.Cleanup();
}
else
{
export.Cleanup();
}
bContinue = pCancel.Continue();
}
catch (Exception e)
{
//错误信息提示
}
}
示例4: ExportPDF
private void ExportPDF(IActiveView activeView, string pathFileName)
{
IExport export = new ExportPDFClass();
export.ExportFileName = pathFileName;
// Microsoft Windows default DPI resolution
export.Resolution = 96;
tagRECT exportRECT = activeView.ExportFrame;
ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
envelope.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
export.PixelBounds = envelope;
System.Int32 hDC = export.StartExporting();
activeView.Output(hDC, (System.Int16)export.Resolution, ref exportRECT, null, null);
// Finish writing the export file and cleanup any intermediate files
export.FinishExporting();
export.Cleanup();
}
示例5: ExportPNG
private void ExportPNG(IActiveView activeView, string pathFileName,IColor bg,string depth)
{
IExport export = new ExportPNGClass();
export.ExportFileName = pathFileName;
IExportPNG png = export as IExportPNG;
png.TransparentColor = bg;
IExportImage img = export as IExportImage;
if(depth=="8bit")
{ img.ImageType = esriExportImageType.esriExportImageTypeIndexed; }
else if(depth=="32bit")
{ img.ImageType = esriExportImageType.esriExportImageTypeTrueColor; }
// Microsoft Windows default DPI resolution
export.Resolution = 96;
tagRECT exportRECT = activeView.ExportFrame;
ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
envelope.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
export.PixelBounds = envelope;
System.Int32 hDC = export.StartExporting();
activeView.Output(hDC, (System.Int16)export.Resolution, ref exportRECT, null, null);
// Finish writing the export file and cleanup any intermediate files
export.FinishExporting();
export.Cleanup();
}
示例6: ExportActiveView
public static void ExportActiveView(IActiveView pActiveView ,string strImagePath)
{
IExporter pExporter;
IEnvelope pEnv;
tagRECT rectExpFrame;
int hdc;
short dpi;
pExporter=new JpegExporterClass();
pEnv=new EnvelopeClass();
//Setup the exporter
rectExpFrame = pActiveView.ExportFrame;
pEnv.PutCoords(rectExpFrame.left,rectExpFrame.top,rectExpFrame.right,rectExpFrame.bottom);
dpi=96;
pExporter.PixelBounds=pEnv;
pExporter.ExportFileName=strImagePath;
pExporter.Resolution=dpi;
hdc=pExporter.StartExporting();
pActiveView.Output(hdc,dpi,ref rectExpFrame,null,null);
pExporter.FinishExporting();
}
示例7: ActiveViewOutput
//使用IActiveView.Output方法输出
//Width和Hight用于设置输出的图片尺寸,默认为0则使用ActiveView.ExportFrame
//VisibleBounds用于设置待输出的地图范围,默认为null则使用ActiveView.Extent
private void ActiveViewOutput(IActiveView docActiveView, int iOutputResolution, int Width, int Height, IEnvelope VisibleBounds, string sExportFileName, IExport docExport)
{
docExport.ExportFileName = sExportFileName;
if (iOutputResolution <= 0) iOutputResolution = 96;
if (Width <= 0 || Height <= 0)
{
Width = docActiveView.ExportFrame.right;
Height = docActiveView.ExportFrame.bottom;
if (Width == 0)
Width = 1024;
if (Height == 0)
Height = 768;
Width = (Width * iOutputResolution) / 96;
Height = (Height * iOutputResolution) / 96;
}
docExport.Resolution = iOutputResolution;
ESRI.ArcGIS.esriSystem.tagRECT exportRECT = new ESRI.ArcGIS.esriSystem.tagRECT();
exportRECT.left = 0;
exportRECT.top = 0;
exportRECT.right = Width;
exportRECT.bottom = Height;
IEnvelope envelope = new EnvelopeClass();
envelope.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
docExport.PixelBounds = envelope;
System.Int32 hDC = docExport.StartExporting();
docActiveView.Output(hDC, iOutputResolution, ref exportRECT, VisibleBounds, null);
docExport.FinishExporting();
docExport.Cleanup();
}
示例8: PrintAuto
// <summary>
/// ��ֽ�Ŵ�ӡ��ͼ //by yl [email protected] 2008.6.18
/// </summary>
/// <param name="pActiveView"></param>
/// <param name="pscale"></param>
private void PrintAuto(IActiveView pActiveView)
{
try
{
IPaper pPaper = new Paper();
IPrinter pPrinter = new EmfPrinterClass();
System.Drawing.Printing.PrintDocument sysPrintDocumentDocument = new System.Drawing.Printing.PrintDocument();
pPaper.PrinterName = sysPrintDocumentDocument.PrinterSettings.PrinterName;
pPrinter.Paper = pPaper;
int Resolution = pPrinter.Resolution;
double w, h;
IEnvelope PEnvelope = pActiveView.Extent;
w = PEnvelope.Width;
h = PEnvelope.Height;
double pw, ph;//ֽ��
pPrinter.QueryPaperSize(out pw, out ph);
tagRECT userRECT = pActiveView.ExportFrame;
userRECT.left = (int)(pPrinter.PrintableBounds.XMin * Resolution);
userRECT.top = (int)(pPrinter.PrintableBounds.YMin * Resolution);
if ((w / h) > (pw / ph))//�Կ���������߶�
{
userRECT.right = userRECT.left + (int)(pPrinter.PrintableBounds.Width * Resolution);
userRECT.bottom = userRECT.top + (int)((pPrinter.PrintableBounds.Width * Resolution) * h / w);
}
else
{
userRECT.bottom = userRECT.top + (int)(pPrinter.PrintableBounds.Height * Resolution);
userRECT.right = userRECT.left + (int)(pPrinter.PrintableBounds.Height * Resolution * w / h);
}
IEnvelope pDriverBounds = new EnvelopeClass();
pDriverBounds.PutCoords(userRECT.left, userRECT.top, userRECT.right, userRECT.bottom);
ITrackCancel pCancel = new CancelTrackerClass();
int hdc = pPrinter.StartPrinting(pDriverBounds, 0);
pActiveView.Output(hdc, pPrinter.Resolution,
ref userRECT, pActiveView.Extent, pCancel);
pPrinter.FinishPrinting();
}
catch (Exception e)
{
}
}