Select to view content in your preferred language

Convert Map to Image (.jpg .....)

6075
4
05-29-2010 04:54 PM
ashrafelhakim
Deactivated User
hey all....
How to convert Map to Image to use it
thx 🙂
0 Kudos
4 Replies
NirYoscovitz
Emerging Contributor
Hi,

You should use the IExport interface.
See the "Create JPEG from ActiveView" code snippet to see how it's done.

Regards,
Nir

#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
0 Kudos
LeLong
by
New Contributor
Sorry to bring this up...
Hi NirNir,
Thanks for your post about "Create JPEG from ActiveView" code snippet. It's really helpful. I have a question about this subject. Is there another way to convert Map to JPEG without ActiveView?

Because I'm making a server without interface, only a log form to see which clients connect and what they do, so I don't think my application could use the IActiveView, or could it be used without loading the map in the main form of my application?

Sorry I'm new to ArcGIS so I really appreciate the help. Thanks in advance.
0 Kudos
arronlee
Deactivated User
Hi, guys.
As you see, there are many free conversion tools online. But I don't suggest you to use them to do with your
image conversion program. Because I always believe that the free tools online do not have so many professional functions as the paid ones. And it is said that some of them might contain some virus. Check some free trials of the paid professional conversion tools to convert image file to word doc first before you make your final decision if possible. I also suggest you choose one whose way of processing is simple and fast. It can save a lot of time for you. Remember to do your conversion work according to its conversion tutorial page about how to convert document image using C#.NET. I hope you success. Good luck.



Best regards,
Arron
0 Kudos
HILLARYHALL
Emerging Contributor
I don't agree with the idea of using jpeg creating application to convert map into jpeg image. It is obvious that as long as we implement and use an image converting tool, we can quickly load the map in the image converting software, then choose the outputting image file "jpeg", then we can simply convert and export the map into jpeg image file.
0 Kudos