I'd like to get the pixel width and height from the MapView.Active.Extent or Camera or Geometry to feed ExportFormat's Height/Width. I do this so the exported dimensions of the Tiff etc. match the MapView Extent as the user might expect.
I can cheat to get usable (printable) results from ExportFormat with the parameter settings formula below:
(96ppi resolution, 1080p height, 1920 width)*3
Resolution = 288,
Height = 3240,
Width = 5760,
Exporting a .tiff produces a 1MB file that does not truncate the mapview if the native resolution of your monitor is 1920x1080.
This is a cheat, not a real solution to the question above.
Thanks, Charles. .GetViewSize() is what I needed, but I still had to implement the 'cheat' above to get anything that resembled the actual mapview aspect ratio without truncating it. (This interface won't let me attach images above 1920x1080.) I believe this method would ALSO work if the user merely wanted a low-res screenshot--just delete the *3 multipliers from resolution, height, width. Here's where I ended up:
private async void Xprt_mv_Click(object sender, EventArgs e)
if (File.Exists(GVar.DL + @"temp\MapView.tiff"))
File.Delete(GVar.DL + @"temp\MapView.tiff");
if (File.Exists(GVar.DL + @"temp\MapView.tfw"))
File.Delete(GVar.DL + @"temp\MapView.tfw");
await QueuedTask.Run(() =>
MapView activeMapView = MapView.Active;
var mvs = activeMapView.GetViewSize(); //get active mapview size
double mvsh = (mvs.Height)*3; //set height variable *3 for printable resolution
double mvsw = (mvs.Width)*3; //set width variable *3 for printable resolution
int ResoMultiplied = 96 * 3; //native System display resolution 96ppi *3 for printable resolution
if (activeMapView != null)
TIFFFormat Tiff = new TIFFFormat()
Resolution = ResoMultiplied, //use resolution multiplied
Height = mvsh, //use height variable
Width = mvsw, //use width variable
HasWorldFile = true,
OutputFileName = GVar.DL + @"temp\MapView.tiff"
//Export active map view
string filepath = GVar.DL + @"temp\";
MessageBox.Show("Could not open the image's containing folder because it does not exist.", " Missing FilePath",
// emf, eps, gif, jpeg, pdf, png, svg, tga, tiff formats also available for export