I have used the following code to crop an image so that it should fit into some fixed size (ex: 100*100)
if(newSize.width == Thumbnail_Size) // Thumbnail_Size 100.0
{
CGFloat side = width;
if(width > height)
{
side = height;
}
CGRect croppedRect = CGRectMake(0, 0, side, side);
CGImageRef croppedImage = CGImageCreateWithImageInRect(image.CGImage, croppedRect);
newImage = [[UIImage alloc] initWithCGImage:croppedImage];
if(newImage == nil) NSLog(@"could not scale image");
return newImage ;
}
but the quality of the image is not good. Images are appearing as in the below screenshot:
I have set the imageview's contentmode as UIViewContentModeScaleAspectFit
[imageView setContentMode:UIViewContentModeScaleAspectFit];
What else I need to do to maintain the quality of the cropped image?