首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在iOS 6.0中将彩色图像转换为黑白图像?

如何在iOS 6.0中将彩色图像转换为黑白图像?
EN

Stack Overflow用户
提问于 2012-09-24 13:58:44
回答 1查看 1.3K关注 0票数 1

我正在使用下面的代码转换黑白图像。它工作得很好。但是我改变了图像的亮度和对比度。应用程序仅在iOS 6.0上崩溃。我使用的是不推荐使用的方法吗?请帮帮我。使用此链接https://github.com/esilverberg/ios-image-filters更改亮度和对比度

代码语言:javascript
复制
- (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;
}

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-24 14:00:40

检查以下链接以获取不推荐使用的方法的列表

https://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html

http://www.bgr.com/2012/07/16/ios-6-download-beta-3-change-log/

https://developer.apple.com/library/mac/#releasenotes/DeveloperTools/RN-Xcode/_index.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12559595

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档