iPhone开发之小技巧:图片缩放(4)
[plain]static UIImage *shrinkImage(UIImage *original,CGSize size)
{
CGFloat scale = [UIScreen mainScreen].scale;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, size.width*scale, size.height*scale, 8, 0, colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(context, CGRectMake(0, 0, size.width*scale, size.height*scale), original.CGImage);
CGImageRef shrunken = CGBitmapContextCreateImage(context); www.zzzyk.com
UIImage *final = [UIImage imageWithCGImage:shrunken];
CGContextRelease(context);
CGImageRelease(shrunken);
return final;
}
作者:js_dada
补充:移动开发 , IOS ,