/// <summary> /// 导出图片 /// </summary> public void ExportPictureMyself(string fileName) { IActiveView pActiveView = pagelayout.ActiveView; IEnvelope pEnv; int iOutputResolution = 600; int iScreenResolution = 96; int hDC; tagRECT exportRECT; exportRECT.left = 0; exportRECT.top = 0; exportRECT.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution); exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution); pEnv = new EnvelopeClass(); pEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom); IExportFileDialog pExportFileDialog = new ExportFileDialogClass(); string filename = fileName; IExport pExport = new ExportJPEGClass(); pExport.ExportFileName = filename; pExport.Resolution = iOutputResolution; pExport.PixelBounds = pEnv; hDC = pExport.StartExporting(); pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null); pExport.FinishExporting(); pExport.Cleanup(); }
/// <summary> /// 导出图片 /// </summary> public void ExportPictureMyself(string fileName) { IActiveView pActiveView = pagelayout.ActiveView; IEnvelope pEnv; int iOutputResolution = 600; int iScreenResolution = 96; int hDC; tagRECT exportRECT; exportRECT.left = 0; exportRECT.top = 0; exportRECT.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution); exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution); pEnv = new EnvelopeClass(); pEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom); IExportFileDialog pExportFileDialog = new ExportFileDialogClass(); string filename = fileName; IExport pExport = new ExportJPEGClass(); pExport.ExportFileName = filename; pExport.Resolution = iOutputResolution; pExport.PixelBounds = pEnv; hDC = pExport.StartExporting(); pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null); pExport.FinishExporting(); pExport.Cleanup(); }
public void ExportFileDialog() { IActiveView pActiveView; IEnvelope pPixelBoundsEnv; int iOutputResolution; int iScreenResolution; int hDC; pActiveView = m_pagelayoutControl.ActiveView; //设置分辨率 iScreenResolution = 96; iOutputResolution = 300; 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);//设置输出范围 IExportFileDialog pExportDialog; pExportDialog = new ExportFileDialogClass(); //使用输出对话框 m_Ok = pExportDialog.DoModal(pPixelBoundsEnv, pActiveView.Extent, pActiveView.Extent, 300); if (!(m_Ok)) { return; //如果按下“取消”键,则退出 } IExport pExport; pExport = pExportDialog.Export;//设置转换输出的属性 pExport.Resolution = iOutputResolution; pExport.PixelBounds = pPixelBoundsEnv; hDC = pExport.StartExporting();//产生文件 pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null); pExport.FinishExporting(); pExport.Cleanup(); }
/// <summary> /// 将当前布局控件的地图内容导出成图片 /// </summary> /// <param name="pActiveView"></param> public static void ExportPictureFile(IActiveView pActiveView) { IEnvelope pPixelBoundsEnv; int hDC; //按输出dpi为300(A4打印的默认dpi)计算图片默认像素宽高 int[] widthHeight = GetPixelSizeImp.GetPixelSize(ExportPageType.A4, 300); tagRECT exportRECT; exportRECT.left = 0; exportRECT.top = 0; exportRECT.right = widthHeight[0]; exportRECT.bottom = widthHeight[1]; pPixelBoundsEnv = new EnvelopeClass(); pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom); IExportFileDialog pExportDialog; pExportDialog = new ExportFileDialogClass(); bool pBool; pBool = pExportDialog.DoModal(pPixelBoundsEnv, pActiveView.Extent, pActiveView.Extent, 300); if (!(pBool)) { return; } IExport pExport; pExport = pExportDialog.Export; exportRECT.right = (int)pExport.PixelBounds.Envelope.XMax; exportRECT.bottom = (int)pExport.PixelBounds.Envelope.YMax; hDC = pExport.StartExporting(); pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null); pExport.FinishExporting(); pExport.Cleanup(); }
/// <summary> /// 导出图片 /// </summary> public void ExportPicture(string strdefaultfilename) { if (strdefaultfilename.Contains("制")) { strdefaultfilename = strdefaultfilename.Replace("制",""); } try { IActiveView pActiveView =axPageLayoutControl1.ActiveView; IEnvelope pEnv; int iOutputResolution = 600; int iScreenResolution = 96; int hDC; tagRECT exportRECT; exportRECT.left = 0; exportRECT.top = 0; //exportRECT.right = pActiveView.ExportFrame.right; //exportRECT.bottom = pActiveView.ExportFrame.bottom; exportRECT.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution); exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution); pEnv = new EnvelopeClass(); pEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom); IExportFileDialog pExportFileDialog = new ExportFileDialogClass(); pExportFileDialog.DocumentName = strdefaultfilename; //bool bl; //bl = pExportFileDialog.DoModal(pEnv, pActiveView.Extent, pActiveView.Extent, 900); //if (!bl) return; //IExport pExport = pExportFileDialog.Export; //pExport.Resolution = iOutputResolution; //pExport.PixelBounds = pEnv; string filename = Application.StartupPath + @"\Image\1.jpg"; if (File.Exists(filename)) { File.Delete(filename); } IExport pExport = new ExportJPEGClass(); pExport.ExportFileName = filename; pExport.Resolution = iOutputResolution; pExport.PixelBounds = pEnv; hDC = pExport.StartExporting(); pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null); pExport.FinishExporting(); pExport.Cleanup(); hDC = pExport.StartExporting(); pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null); pExport.FinishExporting(); pExport.Cleanup(); // MessageBox.Show("保存成功", "提示"); } catch (Exception ax) { MessageBox.Show(ax.ToString()); } //try //{ // System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog(); // sfd.Filter = "*.jpeg|*.jpeg|*.pdf|*.pdf|*.bmp|*.bmp"; // if (sfd.ShowDialog() == DialogResult.OK) // { // IExport pExport = null; // if (1 == sfd.FilterIndex) // { // pExport = new ExportJPEGClass(); // } // else if (2 == sfd.FilterIndex) // { // pExport = new ExportPDFClass(); // } // else if (3 == sfd.FilterIndex) // { // pExport = new ExportBMPClass(); // } // pExport.ExportFileName = sfd.FileName; // //设置参数 // //默认精度 // int reslution = 300; // pExport.Resolution = reslution; // //获取导出范围 // tagRECT exportRECT = axPageLayoutControl1.ActiveView.ExportFrame; // //tagRECT exportRECT = axMapMain.ActiveView.ExportFrame; // IEnvelope pPixelBoundsEnv = new EnvelopeClass(); // pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom); // pExport.PixelBounds = pPixelBoundsEnv; // //开始导出,获取DC // int hDC = pExport.StartExporting(); // IEnvelope pVisbounds = null; // ITrackCancel ptrac = null; // //导出 // axPageLayoutControl1.ActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, pVisbounds, ptrac); // //结束导出 // pExport.FinishExporting(); // //清理导出类 // pExport.Cleanup(); // MessageBox.Show("导出成功","提示"); // } //} //catch //{ //} }
/// <summary> /// 导出图片 /// </summary> public void ExportPicture(string strdefaultfilename) { if (strdefaultfilename.Contains("制")) { strdefaultfilename = strdefaultfilename.Replace("制", ""); } try { IActiveView pActiveView = axPageLayoutControl1.ActiveView; IEnvelope pEnv; int iOutputResolution = 600; int iScreenResolution = 96; int hDC; tagRECT exportRECT; exportRECT.left = 0; exportRECT.top = 0; //exportRECT.right = pActiveView.ExportFrame.right; //exportRECT.bottom = pActiveView.ExportFrame.bottom; exportRECT.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution); exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution); pEnv = new EnvelopeClass(); pEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom); IExportFileDialog pExportFileDialog = new ExportFileDialogClass(); pExportFileDialog.DocumentName = strdefaultfilename; //bool bl; //bl = pExportFileDialog.DoModal(pEnv, pActiveView.Extent, pActiveView.Extent, 900); //if (!bl) return; //IExport pExport = pExportFileDialog.Export; //pExport.Resolution = iOutputResolution; //pExport.PixelBounds = pEnv; string filename = Application.StartupPath + @"\Image\1.jpg"; if (File.Exists(filename)) { File.Delete(filename); } IExport pExport = new ExportJPEGClass(); pExport.ExportFileName = filename; pExport.Resolution = iOutputResolution; pExport.PixelBounds = pEnv; hDC = pExport.StartExporting(); pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null); pExport.FinishExporting(); pExport.Cleanup(); hDC = pExport.StartExporting(); pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null); pExport.FinishExporting(); pExport.Cleanup(); // MessageBox.Show("保存成功", "提示"); } catch (Exception ax) { MessageBox.Show(ax.ToString()); } //try //{ // System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog(); // sfd.Filter = "*.jpeg|*.jpeg|*.pdf|*.pdf|*.bmp|*.bmp"; // if (sfd.ShowDialog() == DialogResult.OK) // { // IExport pExport = null; // if (1 == sfd.FilterIndex) // { // pExport = new ExportJPEGClass(); // } // else if (2 == sfd.FilterIndex) // { // pExport = new ExportPDFClass(); // } // else if (3 == sfd.FilterIndex) // { // pExport = new ExportBMPClass(); // } // pExport.ExportFileName = sfd.FileName; // //设置参数 // //默认精度 // int reslution = 300; // pExport.Resolution = reslution; // //获取导出范围 // tagRECT exportRECT = axPageLayoutControl1.ActiveView.ExportFrame; // //tagRECT exportRECT = axMapMain.ActiveView.ExportFrame; // IEnvelope pPixelBoundsEnv = new EnvelopeClass(); // pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom); // pExport.PixelBounds = pPixelBoundsEnv; // //开始导出,获取DC // int hDC = pExport.StartExporting(); // IEnvelope pVisbounds = null; // ITrackCancel ptrac = null; // //导出 // axPageLayoutControl1.ActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, pVisbounds, ptrac); // //结束导出 // pExport.FinishExporting(); // //清理导出类 // pExport.Cleanup(); // MessageBox.Show("导出成功","提示"); // } //} //catch //{ //} }
public void ExportFileDialog() { IActiveView pActiveView; IEnvelope pPixelBoundsEnv; int iOutputResolution; int iScreenResolution; int hDC; pActiveView = m_pagelayoutControl .ActiveView; //���÷ֱ��� iScreenResolution = 96; iOutputResolution = 300; 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);//���������Χ IExportFileDialog pExportDialog; pExportDialog = new ExportFileDialogClass(); //ʹ������Ի��� m_Ok = pExportDialog.DoModal(pPixelBoundsEnv, pActiveView.Extent,pActiveView.Extent, 300); if (!(m_Ok)) return;//������¡�ȡ�����������˳� IExport pExport; pExport = pExportDialog.Export;//����ת����������� pExport.Resolution = iOutputResolution; pExport.PixelBounds = pPixelBoundsEnv; hDC = pExport.StartExporting();//�����ļ� pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null); pExport.FinishExporting(); pExport.Cleanup(); }