In iOS, my UIImageView is "Aspect Fit", but when I do CIFilter of type e.g. "CISepiaTone", I lose the original image aspect ratio. The image is stretched to whole UIImageView size.
How can I preserve the aspect ratio?
In iOS, my UIImageView is "Aspect Fit", but when I do CIFilter of type e.g. "CISepiaTone", I lose the original image aspect ratio. The image is stretched to whole UIImageView size.
How can I preserve the aspect ratio?
If you are creating the filtered image with imageWithCIImage, then you won't get the proper aspect ratio. Try creating a CGImageRef from the filter output CIImage and then creating the UIImage from the CGImageRef.
Example:
// assume you already have CIImage *outputImage and *inputImage declared
// convert to CGImage to maintain proper aspect ratio and dimensions
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef imageRef = [context createCGImage:outputImage fromRect:inputImage.extent];
UIImage *filteredImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
Then you can try setting the imageView with filteredImage.