ADC Home > Reference Library > Technical Q&As > Graphics & Imaging > Quartz >

Quartz 2D Interpolation


Q: How do I control the interpolation Quartz 2D uses when drawing a CGImageRef into a CGContextRef?

A: To control the degree of interpolation (anti-aliasing quality) for an image, you must first create the image with interpolation enabled (by passing true for the shouldInterpolate parameter of one of the various CGImageCreateXYZ functions). Then, you can specify the interpolation quality on the destination context by calling CGContextSetInterpolationQuality. Currently, the following degrees of interpolation quality are supported:

kCGInterpolationDefaultLet the context decide based on its knowledge of the destination device. In general, this will produce medium quality, reasonably fast interpolation.
kCGInterpolationNoneNever interpolate.
kCGInterpolationLowFast, low quality interpolation.
kCGInterpolationHighSlower, high quality interpolation.

Note that the interpolation quality setting is merely a hint to the context since not all contexts support all interpolation quality levels.

CGImageRef is defined in "CGImage.h" and CGContextSetInterpolationQuality is located in "CGContext.h". More information about Quartz 2D can be found on the Quartz 2D reference page.

For those that are curious, interpolation is the calculation of the value of a function between the values already known. ( WordNet ® 1.6 © 1997 Princeton University ). In graphics programming, interpolation is the general method used in re-sampling digital images. It involves the process of estimating and inserting new pixel values between existing values. Different interpolation algorithms are used in a tradeoff between rendering speed and the desired quality of the final image.


[Oct 29 2002]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.