English

How To: Set the ArcMap Output Image Quality (OIQ) ratio using Visual Basic

Summary

The Output Image Quality (OIQ) setting is used to control the resampling of raster elements when outputting a map.

This setting can be controlled programatically, but the user must ensure that it is set for each data frame in the document.

Procedure

Use the code snippet below:

Code:
Private Sub ResetOutputQualityToBest()

On Error GoTo EH

Dim pActiveView As IActiveView
Dim pDisplayTrans As IOutputRasterSettings
Dim pMxDoc as IMxDocument
Set pMxDoc = ThisDocument

' This will change the setting in the 'File | Page Setup' dialog,
' but does not affect each map until the document is reopened...
Set pActiveView = pMxDoc.PageLayout
Set pDisplayTrans = pActiveView.ScreenDisplay.DisplayTransformation

If pDisplayTrans.ResampleRatio <> esriRasterOutputBest Then
pDisplayTrans.ResampleRatio = esriRasterOutputBest
End If

' ...so we will additionally set the output quality for each map so
' the current export works correctly.
Dim pMaps As IMaps
Set pMaps = pMxDoc.Maps
Dim lMapIndex As Long

For lMapIndex = 0 To (pMaps.Count - 1)
Set pActiveView = pMaps.Item(lMapIndex)
Set pDisplayTrans = pActiveView.ScreenDisplay.DisplayTransformation

If pDisplayTrans.ResampleRatio <> esriRasterOutputBest Then
pDisplayTrans.ResampleRatio = esriRasterOutputBest
End If
Next lMapIndex

Exit Sub

EH:
Err.Raise Err.Number, "MapsOnDemand.ResetOutputQualityToBest", Err.Description

End Sub

The ResampleRatio can be set to any integer from 1 through 5, or to a member of the following enumeration:

Code:
tagesriResampleRatioType
1 - esriRasterOutputBest
3 - esriRasterOutputNormal
5 - esriRasterOutputDraft

Related Information