How to scale UIImage without smoothing anything?

I want to scale the UIImage so that the user can see the pixels in UIImage very sharp. When I put this in a UIImageView and scale the transformation matrix, the UIImage looks smoothed and smoothed.

Is there a way to render in a larger raster context by simply repeating each row and each column to get more pixels? How can i do this?

+7
iphone cocoa-touch uikit core-graphics uiimage
source share
5 answers

#import <QuartzCore/CALayer.h>

view.layer.magnificationFilter = kCAFilterNearest

+20
source share

When drawing directly in a raster context, we can use:

 CGContextSetInterpolationQuality(myBitmapContext, kCGInterpolationNone); 

I found this on CGContextDrawImage very slowly on iPhone 4

+2
source share

Try to answer this question .

+1
source share

I also tried to do this (on the sublayer), and I could not get it to work, it was still blurry. This is what I had to do:

 const CGFloat PIXEL_SCALE = 2; layer.magnificationFilter = kCAFilterNearest; //Nearest neighbor texture filtering layer.transform = CATransform3DMakeScale(PIXEL_SCALE, PIXEL_SCALE, 1); //Scale layer up //Rasterize w/ sufficient resolution to show sharp pixels layer.shouldRasterize = YES; layer.rasterizationScale = PIXEL_SCALE; 
+1
source share

For a UIImage created from CIImage, you can use:

 imageView.image = UIImage(CIImage: ciImage.imageByApplyingTransform(CGAffineTransformMakeScale(kScale, kScale))) 
-one
source share

All Articles