How do I turn off all image processing to see actual, unmodified pixels when I zoom in?

I have an application that needs to be scaled far enough in the images so that I can clearly see the individual pixels in the image. I need to see clear squares of the same color, without smoothing or other commonly useful methods for a good display image. How can I strangle all this help? Here is code that works, but scales to blurry, adjusted pixels:

- (void)drawRect:(CGRect)rect { CGRect photoRect = CGRectMake(currentTarget.origin.x, currentTarget.origin.y, currentTarget.size.width, currentTarget.size.height); CGContextRef context = UIGraphicsGetCurrentContext() ; CGContextSaveGState(context); CGImageRef subImageRef = CGImageCreateWithImageInRect(sourceImage.CGImage, photoRect); UIImage *subImage = [UIImage imageWithCGImage:subImageRef]; [subImage drawInRect:rect]; CGImageRelease(subImageRef); CGContextRestoreGState(context); CGContextFlush(context); } 
+7
ios image antialiasing
source share
1 answer

Adjusting the quality of interpolation for the context should help solve this problem, although if you allow the user to zoom in with a 1: 1 ratio, everything will look somewhat soft.

 CGContextSetInterpolationQuality(context, kCGInterpolationNone) 

In this case, I used kCGInterpolationNone , which is actually the “nearest neighbor”.

For more information, see the Apple help documentation .

+4
source share

All Articles