I'm making a little project that provides the ability to enlarge an image and pick pixels' colors from the magnifier, now I can magnify the touched place of the image, but the magnifier shows the pixels with blurry effect, how can I make it show the pixels one by one very clearly without any fuzzy processing?
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect bounds = self.bounds;
CGImageRef mask = [UIImage imageNamed: @"[email protected]"].CGImage;
UIImage *glass = [UIImage imageNamed: @"[email protected]"];
CGContextSaveGState(context);
CGContextClipToMask(context, bounds, mask);
CGContextFillRect(context, bounds);
CGContextScaleCTM(context, 40, 40);
//draw your subject view here
CGContextTranslateCTM(context,1*(self.frame.size.width*0.5),1*(self.frame.size.height*0.5));
//CGContextScaleCTM(context, 1.5, 1.5);
CGContextTranslateCTM(context,-1*(touchPoint.x),-1*(touchPoint.y));
[self.viewToMagnify.layer renderInContext:context];
CGContextRestoreGState(context);
[glass drawInRect: bounds];
}
Should be:
Should not be:
You want to set a drawing mode that scaled pixels rather than interpolating. I think for the drawing you're doing you want the CGContext command CGContextSetInterpolationQuality, with a value of kCGInterpolationNone.
(Disclaimer: I think this is the setting, but I'm not positive, and haven't tried it.)
BTW, it's probably best to avoid images that anywhere close to NSFW on this site. This site is read all over the world, and I'm sure plenty of people read it at work. Different workplaces have widely different standards of what's acceptable. Your sample image is pretty risqué.