views:

593

answers:

2

I have a UIImageView showing a image that is larger than it's frame.
It's set to rescale the image to fit it's frame. But, the image is scaled with a low quality filter.

I've read here that this is caused by it using a low interpolation quality.

How can I get it's context to CGContextSetInterpolationQuality to kCGInterpolationHigh?

A: 

CGContextSetInterpolationQuality is a function. You need to call it with whatever parameters are appropriate for your situation.

http://developer.apple.com/mac/library/qa/qa2001/qa1186.html

Azeem.Butt
And where do you call this function to apply it to the UIImageView's drawing?
Peter Hosey
I'd draw the image into a new context using this setting, take the resulting UIImage, and set the UIImageView.image property to the refined image.
Kendall Helmstetter Gelner
+1  A: 

UIImageView does not offer this functionality, though UIImage has an undocumented _imageScaledToSize:interpolationQuality: method if I remember correctly.

Since UIImageView draws directly to the display, subclassing and overriding drawRect: is no option (thanks to Prody for pointing this out). The only option I see is to create a custom UIView subclass with a custom drawrect: implementation.

Ole Begemann
From the docs: The UIImageView class is optimized to draw its images to the display. UIImageView will not call drawRect:. I can't find any mention of _imageScaledToSize:interpolationQuality. I guess for now I'll draw my image in the parent view's drawRect.
Prody
Thanks for the correction, Prody. I should have read the docs before posting. I will edit my answer accordingly.
Ole Begemann