#region"Create JPEG from ActiveView" // ArcGIS Snippet Title: // Create JPEG from ActiveView // // Long Description: // Creates a .jpg (JPEG) file from IActiveView. Default values of 96 DPI are used for the image creation. // // Add the following references to the project: // ESRI.ArcGIS.Carto // ESRI.ArcGIS.Display // ESRI.ArcGIS.Geometry // ESRI.ArcGIS.Output // ESRI.ArcGIS.System // // Intended ArcGIS Products for this snippet: // ArcGIS Desktop (ArcEditor, ArcInfo, ArcView) // ArcGIS Engine // ArcGIS Server // // Applicable ArcGIS Product Versions: // 9.2 // 9.3 // // Required ArcGIS Extensions: // (NONE) // // Notes: // This snippet is intended to be inserted at the base level of a Class. // It is not intended to be nested within an existing Method. // ///<summary>Creates a .jpg (JPEG) file from IActiveView. Default values of 96 DPI are used for the image creation.</summary> /// ///<param name="activeView">An IActiveView interface</param> ///<param name="pathFileName">A System.String that the path and filename of the JPEG you want to create. Example: "C:\temp\test.jpg"</param> /// ///<returns>A System.Boolean indicating the success</returns> /// ///<remarks></remarks> public System.Boolean CreateJPEGFromActiveView(ESRI.ArcGIS.Carto.IActiveView activeView, System.String pathFileName) {  //parameter check  if (activeView == null || !(pathFileName.EndsWith(".jpg")))  {    return false;  }  ESRI.ArcGIS.Output.IExport export = new ESRI.ArcGIS.Output.ExportJPEGClass();  export.ExportFileName = pathFileName;  // Microsoft Windows default DPI resolution  export.Resolution = 96;  ESRI.ArcGIS.Display.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();  return true; } #endregion
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.