Hello All
I am scaling images by myself using the following codes. The code is fine and the images are scaled without problem.
UIImage *originImg = img;
size = newSize;
if (originImg.size.width > originImg.size.height) {
newSize = CGSizeMake(size.width, originImg.size.height * size.width / originImg.size.width);
} else {
newSize = CGSizeMake(originImg.size.width * size.height / originImg.size.height, size.height);
}
UIGraphicsBeginImageContext(newSize);
CGContextRef context = CGContextRetain(UIGraphicsGetCurrentContext());
CGContextTranslateCTM(context, 0.0, newSize.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, newSize.width, newSize.height), originImg.CGImage);
UIImage* scaledImage = [UIGraphicsGetImageFromCurrentImageContext() retain];
UIGraphicsEndImageContext();
CGContextRelease(context);
The only problem is that the scaling process from this code is very slow. Can someone point out how to improve it?
thanks