Tag: magnify

如何在我的iOS拾色项目中放大图像时防止像素变得模糊?

我正在做一个能够放大图像并从放大镜中选取像素颜色的小工程,现在我可以放大图像的触摸位置,但是放大镜显示的是模糊效果的像素,我怎样才能使它不用模糊处理就可以一目了然地显示像素了吗? – (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGRect bounds = self.bounds; CGImageRef mask = [UIImage imageNamed: @"loupe-mask@2x.png"].CGImage; UIImage *glass = [UIImage imageNamed: @"loupe-hi@2x.png"]; 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]; } 应该: 不应该是: