Cocoa -Touch: How to set the interpolation quality to be used by UIImageView?

I have a UIImageView showing an image that is larger than its frame.
It sets the image scaling to fit its frame. But the image is scaled with a low quality filter.

I read here that this is caused by this using low quality interpolation.

How can I get context from CGContextSetInterpolationQuality to kCGInterpolationHigh ?

+4
source share
3 answers

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

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

+1
source

From UIImageView's scaling / interpolation , this is the most optimized way to do this if you can:

 [[yourimageview layer] setMagnificationFilter:kCAFilterTrilinear] 

Required #import <QuartzCore/CALayer.h>

KCAFilterTrilinear warning: "Some renderers may ignore this or impose additional restrictions, such as source images that require two-dimensional power measurements."

+2
source

CGContextSetInterpolationQuality is a function. You need to call him with any parameters suitable for your situation.

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

+1
source

All Articles