iOS CGImageRef
来源:互联网 发布:sar源码 编辑:程序博客网 时间:2024/04/28 13:38
图片截取
UIImageView * imgView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 100, 420, 375)]; [self.view addSubview:imgView]; UIImage * img =[UIImage imageNamed:@"zc.jpg"]; CGImageRef imgRef =[img CGImage]; //截取位置 imgRef =CGImageCreateWithImageInRect(imgRef, CGRectMake(0, 0, 420, 400)); img =[UIImage imageWithCGImage:imgRef]; imgView.image =img;
注:imgView.contentMode =UIViewContentModeScaleAspectFill; //保持图片原有比例拉伸,默认是哪里短哪里拉伸。
调整图片尺寸
UIGraphicsBeginImageContextWithOptions(CGSizeMake(200, 200), NO, 0.0f); [img drawInRect:CGRectMake(0, 0, 200, 200)]; UIImage * newImage =UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
注:创建一个200*200的画布,将图片画在指定范围。
Core Image过滤器
imgView =[[UIImageView alloc]initWithFrame:CGRectMake(20, 80, 150, 150)]; imgView.image =[UIImage imageNamed:@"zc.jpg"]; [self.view addSubview:imgView]; UISlider * slider =[[UISlider alloc]initWithFrame:CGRectMake(20, 250, 200, 20)]; slider.maximumValue =1.0f; slider.minimumValue =-1.0f; slider.value=0.0f; [slider addTarget:self action:@selector(changeValue:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:slider]; _context =[CIContext contextWithOptions:nil]; _filter =[CIFilter filterWithName:@"CIColorControls"]; //设置输入源 [_filter setValue:[CIImage imageWithCGImage:[UIImage imageNamed:@"zc.jpg"].CGImage] forKey:@"inputImage"];}-(void)changeValue:(UISlider *)slider{ //设置滤镜参数 [_filter setValue:[NSNumber numberWithFloat:slider.value] forKey:@"inputSaturation"]; //取得输出图像 CIImage *outputImage =[_filter outputImage]; //转格式 CGImageRef temp =[_context createCGImage:outputImage fromRect:[outputImage extent]]; UIImage * newImage =[UIImage imageWithCGImage:temp]; imgView.image =newImage;}
注:@import CoreImage; 加CoreImage.framework
0 0
- iOS CGImageRef
- iOS CGImageRef 对图片进行处理
- ioS:How to create a ARGB CGImageRef from a ABGR CGImageRef in Cocoa
- (ios)UIImage,CGImage和CGImageRef之间的转化
- IOS中使用像素位图(CGImageRef)对图片进行处理
- IOS中使用像素位图(CGImageRef)对图片进行处理
- 【IOS 开发学习总结-OC-63】UIImage 与 CGImage,CGImageRef
- IOS中使用像素位图(CGImageRef)对图片进行处理
- IOS中使用像素位图(CGImageRef)对图片进行处理
- iOS 通过CGImageRef来进行图片的截取、裁剪
- iOS中的CALayer、CGImageRef和UIimage的区别
- iOS中使用像素位图(CGImageRef)对图片进行处理
- 关于CGImageRef
- ios (Quartz 2D绘图) UIImage,CGImage和CGImageRef有什么区别
- CGImageRef 的 参数解释
- CGImageRef与UIImage互转
- CGImageRef内存泄漏问题
- CGImageRef 图片压缩 裁减
- iOS - 关于支付宝的集成
- SpringMVC上传文件的三种方式
- Paint类
- Intent传递实现Parcelable接口对象
- Oracle数据库表空间
- iOS CGImageRef
- linux下使用mkae_rt命令打包idl code为可执行程序
- 利用AJAX读取本地xml
- fullpage插件动态添加节点,页面不能动态渲染问题解决方法
- System.arraycopy
- Android Studio没有SVN菜单
- mathematica--关联
- 目标检测
- 【kuangbin带你飞】之【搜索】 poj1321 棋盘问题