iOS:获取图片Alpha图片
来源:互联网 发布:ketchup免费mac破解版 编辑:程序博客网 时间:2024/05/21 08:01
-(void)createImages{ // Load the alpha image, which is just the same Ship.png image used in the clipping demo NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"Ship.png" ofType:nil]; UIImage *img = [UIImage imageWithContentsOfFile:imagePath]; _alphaImage = CGImageRetain(img.CGImage); // To show the difference with an image mask, we take the above image and process it to extract // the alpha channel as a mask. // Allocate data NSMutableData *data = [NSMutableData dataWithLength:90 * 90 * 1]; // Create a bitmap context CGContextRef context = CGBitmapContextCreate([data mutableBytes], 90, 90, 8, 90, NULL, (CGBitmapInfo)kCGImageAlphaOnly); // Set the blend mode to copy to avoid any alteration of the source data CGContextSetBlendMode(context, kCGBlendModeCopy); // Draw the image to extract the alpha channel CGContextDrawImage(context, CGRectMake(0.0, 0.0, 90.0, 90.0), _alphaImage); // Now the alpha channel has been copied into our NSData object above, so discard the context and lets make an image mask. CGContextRelease(context); // Create a data provider for our data object (NSMutableData is tollfree bridged to CFMutableDataRef, which is compatible with CFDataRef) CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFMutableDataRef)data); // Create our new mask image with the same size as the original image _maskingImage = CGImageMaskCreate(90, 90, 8, 8, 90, dataProvider, NULL, YES); // And release the provider. CGDataProviderRelease(dataProvider);}
0 0
- iOS:获取图片Alpha图片
- ios获取网络图片
- IOS获取系统图片
- iOS 获取图片路径
- iOS 获取系统图片
- iOS-获取启动图片
- alpha:图片的透明度
- 图片的alpha 通道
- ios获取本地图片以及图片信息
- iOS WebView 获取内存图片 图片点击
- IOS获取网络图片属性
- IOS 获取视频图片的
- ios获取本地所有图片
- 获取ios设备所有图片
- ios之获取图库图片
- iOS----ALAssetsLibrary获取所有图片
- iOS ALAssetsLibrary获取所有图片
- IOS获取图片进行压缩
- 统计学习笔记(2)——感知机模型
- java异常
- sqlserver 查看进程及杀锁
- fread读取结构体注意事项
- 可穿戴设备还能怎么玩
- iOS:获取图片Alpha图片
- python 添加中文注释
- 一道ThoughtWorks的面试编程题
- SQL SERVER各种服务解释
- 理解HTTP缓存
- ExtJS表单验证
- 很高兴来到CSDN大家庭
- IOS应用开发版本控制工具之Versions使用
- Android上传文件到Web服务器,PHP接收文件(一)