Arcengine, C #, a simple way to output raster pictures

Source: Internet
Author: User

<summary>

A simple way to map out raster pictures, returning the filename of the output by YL landgis@126.com

</summary>

<param name= "Pactiveview" ></param>

<returns></returns>

public static string Exportimage (Iactiveview pactiveview)

{

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 = "Output map";

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 ("Output format error");

return null;

}

Ienvelope penvelope = new Envelopeclass ();

Itrackcancel ptrackcancel = new Canceltrackerclass ();

Tagrect Ptagrect;

Ptagrect.left = 0;

ptagrect.top = 0;

Ptagrect.right = (int) pActiveView.Extent.Width;

Ptagrect.bottom = (int) pActiveView.Extent.Height;

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 ();

Releasing resources

Psavefiledialog.dispose ();

System.Runtime.InteropServices.Marshal.ReleaseComObject (Pexporter);

return FileName;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.