1
我使用下面的代码来转换黑白图像。它的工作正常。但是我改变了图像的亮度和对比度。应用程序仅在iOS 6.0上崩溃。我使用任何已弃用的方法?请帮帮我。更改亮度和对比度通过此链接提前https://github.com/esilverberg/ios-image-filters如何在iOS 6.0中将彩色图像更改为黑白图像?
- (UIImage *)convertImageToGrayScale:(UIImage *)image
{
CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
CGContextRef context = CGBitmapContextCreate(nil, image.size.width, image.size.height, 8, 0, colorSpace, kCGImageAlphaNone);
CGContextDrawImage(context, imageRect, [image CGImage]);
CGImageRef imageRef = CGBitmapContextCreateImage(context);
UIImage *newImage = [UIImage imageWithCGImage:imageRef];
CGColorSpaceRelease(colorSpace);
CGContextRelease(context);
CFRelease(imageRef);
return newImage;
}
感谢。
感谢吉尔列表以下链接...我会检查.. – Mani