I noticed the resolution of a programmatically exported raster was not as good as the same image exported with the ArcMap GUI. I set the resample ratio in the GUI to 3 and the quality seemed identical. I tried to do the same thing in code but it doesn't seem to be changing the quality at all:

private static IExport GetExporterObject()
    IExport newExporter = new ExportPDFClass();
    IOutputRasterSettings rasterSettings = (newExporter as IOutputRasterSettings);
    rasterSettings.ResampleRatio = 1;
    return (IExport)rasterSettings;

private static IEnvelope GetExporterRectangle(double ratio, IActiveView activeView, out tagRECT exporterRectangle)
    IEnvelope pixelBox = new EnvelopeClass();
    pixelBox.XMin = activeView.ExportFrame.left * ratio;
    pixelBox.XMax = activeView.ExportFrame.right * ratio;
    pixelBox.YMin = activeView.ExportFrame.top * ratio;
    pixelBox.YMax = activeView.ExportFrame.bottom * ratio;

    //I did the following code this way because I found that converting the ratio to int  
    //was rounding it down before multiplying and giving me the wrong dimensions
    exporterRectangle.left = (int)(activeView.ExportFrame.left * ratio);
    exporterRectangle.right = (int)(activeView.ExportFrame.right * ratio);
    exporterRectangle.top = (int)(activeView.ExportFrame.top * ratio);
    exporterRectangle.bottom = (int)(activeView.ExportFrame.bottom * ratio);

    return pixelBox;

public static void ExportMapPage(IMxDocument mxd, MapPage mapPage, string outputPath)
    mxd.ActiveView = mxd.PageLayout as IActiveView;
    IActiveView activeView = mxd.ActiveView;
    activeView.FocusMap.MapScale = mapPage.Scale;
    mxd.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, activeView.Extent);
    string output = String.Format("{0}\\{1}{2}", outputPath, mapPage.Year, GetFileExtension(mapPage.FileFormat));

    IExport exporter = GetExporterObject();
    exporter.ExportFileName = output;
    exporter.Resolution = mapPage.DPI;

    tagRECT exporterRectangle;
    exporter.PixelBounds = GetExporterRectangle(mapPage.Ratio, activeView, out exporterRectangle);

    int hdc = exporter.StartExporting();
    activeView.Output(hdc, (int)exporter.Resolution, ref exporterRectangle, null, null);

I also noticed in the documentation there appears to be a discrepency.

This link says DisplayTransformation is the only coclass that implements IOutputRasterSettings, while this link says many do. Does anyone know which is correct? I'm using ArcGIS 10.1 SP1 and SDK 10.1 but I'm not sure how that reflects the ArcObjects version I'm using.

EDIT: It appears that DisplayTransformation is the coclass to use. I found that casting IActiveView.ScreenDisplay.DisplayTransformation to IOutputRasterSettings told me that the ResampleRatio property was in fact set to 3 by default. However even when I added this code immediately before the exporter.StartExporting() line, the output still looks the same as the ratio being set to 3.

IDisplayTransformation dispTrans = activeView.ScreenDisplay.DisplayTransformation; 
(dispTrans as IOutputRasterSettings).ResampleRatio = 1;

In the documentation it specifically says at the bottom that changing this property will affect the results of the IActiveView.Output method, so I assume there is something wrong with my code.

1 Answer 1


According to this, you need to loop through the map elements to find the IMapFrame and cast it to IActiveView::IOutputRasterSettings to access the ResampleRatio of the map element. Setting the ratio by having IActiveView set to PageLayout will not affect the resampling of the PageLayout output. With this I was able to get the output quality to look right.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.