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.
[C#]
privatevoid 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 pagelayout.*/
IGraphicsContainer docGraphicsContainer;
IElement docElement;
IOutputRasterSettings docOutputRasterSettings;
IMapFrame docMapFrame;
IActiveView tmpActiveView;
if (docActiveView is IMap)
{
docOutputRasterSettings = docActiveView.ScreenDisplay.DisplayTransformation as IOutputRasterSettings;
docOutputRasterSettings.ResampleRatio = (int)iResampleRatio;
}
elseif (docActiveView is IPageLayout)
{
//Assign ResampleRatio for 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]
PrivateSub SetOutputQuality(ByVal docActiveView As IActiveView, ByVal iResampleRatio AsLong)
Dim docGraphicsContainer As IGraphicsContainer
Dim docElement As IElement
Dim docOutputRasterSettings As IOutputRasterSettings
Dim docMapFrame As IMapFrame
Dim tmpActiveView As IActiveView
IfTypeOf docActiveView Is IMap Then
docOutputRasterSettings = docActiveView.ScreenDisplay.DisplayTransformation
docOutputRasterSettings.ResampleRatio = iResampleRatio
ElseIfTypeOf 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.NextDoWhileNot docElement IsNothingIfTypeOf docElement Is IMapFrame Then
docMapFrame = docElement
tmpActiveView = docMapFrame.Map
docOutputRasterSettings = tmpActiveView.ScreenDisplay.DisplayTransformation
docOutputRasterSettings.ResampleRatio = iResampleRatio
EndIf
docElement = docGraphicsContainer.NextLoop
docMapFrame = Nothing
docGraphicsContainer = Nothing
tmpActiveView = NothingEndIf
docOutputRasterSettings = NothingEndSub