Setting output image quality
The following code example uses an IActiveView and a ResampleRatio (resampling ratio). The resampling ratio works the opposite way that you would expect. A value of 1 is the least resampling and therefore, gives the best output image quality.
- Obtain the IActiveView for the output image quality you want to modify. This can be a map or page layout.
- Call the following function, passing the ActiveView in question with the desired resampling ratio (an integer value from 1 to 5, 1 being the highest quality and 5 being the lowest quality.
private void SetOutputQuality(IActiveView docActiveView, long iResampleRatio)
{
/* This function sets the OutputImageQuality for the active view. If the active view is a pagelayout, then
* it must also set the output image quality for each of the maps in the page layout.
*/
IGraphicsContainer docGraphicsContainer;
IElement docElement;
IOutputRasterSettings docOutputRasterSettings;
IMapFrame docMapFrame;
IActiveView tmpActiveView;
if (docActiveView is IMap)
{
docOutputRasterSettings = docActiveView.ScreenDisplay.DisplayTransformation
as IOutputRasterSettings;
docOutputRasterSettings.ResampleRatio = (int)iResampleRatio;
}
else if (docActiveView is IPageLayout)
{
//Assign ResampleRatio for the PageLayout
docOutputRasterSettings = docActiveView.ScreenDisplay.DisplayTransformation
as IOutputRasterSettings;
docOutputRasterSettings.ResampleRatio = (int)iResampleRatio;
//and assign ResampleRatio to the maps in the PageLayout.
docGraphicsContainer = docActiveView as IGraphicsContainer;
docGraphicsContainer.Reset();
docElement = docGraphicsContainer.Next();
while (docElement != null)
{
if (docElement is IMapFrame)
{
docMapFrame = docElement as IMapFrame;
tmpActiveView = docMapFrame.Map as IActiveView;
docOutputRasterSettings =
tmpActiveView.ScreenDisplay.DisplayTransformation as
IOutputRasterSettings;
docOutputRasterSettings.ResampleRatio = (int)iResampleRatio;
}
docElement = docGraphicsContainer.Next();
}
docMapFrame = null;
docGraphicsContainer = null;
tmpActiveView = null;
}
docOutputRasterSettings = null;
}
[VB.NET]
Private Sub SetOutputQuality(ByVal docActiveView As IActiveView, ByVal iResampleRatio As Long)
Dim docGraphicsContainer As IGraphicsContainer
Dim docElement As IElement
Dim docOutputRasterSettings As IOutputRasterSettings
Dim docMapFrame As IMapFrame
Dim tmpActiveView As IActiveView
If TypeOf docActiveView Is IMap Then
docOutputRasterSettings = docActiveView.ScreenDisplay.DisplayTransformation
docOutputRasterSettings.ResampleRatio = iResampleRatio
ElseIf TypeOf docActiveView Is IPageLayout Then
'Assign ResampleRatio for PageLayout
docOutputRasterSettings = docActiveView.ScreenDisplay.DisplayTransformation
docOutputRasterSettings.ResampleRatio = iResampleRatio
'and assign ResampleRatio to the maps in the PageLayout.
docGraphicsContainer = docActiveView
docGraphicsContainer.Reset()
docElement = docGraphicsContainer.Next
Do While Not docElement Is Nothing
If TypeOf docElement Is IMapFrame Then
docMapFrame = docElement
tmpActiveView = docMapFrame.Map
docOutputRasterSettings = tmpActiveView.ScreenDisplay.DisplayTransformation
docOutputRasterSettings.ResampleRatio = iResampleRatio
End If
docElement = docGraphicsContainer.Next
Loop
docMapFrame = Nothing
docGraphicsContainer = Nothing
tmpActiveView = Nothing
End If
docOutputRasterSettings = Nothing
End Sub
To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing | Deployment licensing |
---|---|
Engine Developer Kit: Military Analyst | ArcGIS for Desktop Basic |
ArcGIS for Desktop Basic | ArcGIS for Desktop Standard |
ArcGIS for Desktop Standard | ArcGIS for Desktop Advanced |
ArcGIS for Desktop Advanced | Engine |