您的位置:首页 > 其它

CoreImage的初步学习二

2016-03-10 17:25 211 查看
趁着还有一点时间,把初步学习一中的一点疑问解决掉去,

经过了初步学习一,现在看那个学习博客关于CIFilter的介绍已经分分钟看懂了

来:学习博客关于CIFilter我就以下总结:

[CIFilterfilterNamesInCategory:kCICategoryBuiltIn];//搜索属于 kCICategoryBuiltIn类别的所有滤镜名字,返回一个数组;
[CIFilterfilterNamesInCategories];//搜索所有可用的滤镜名称;
调用[CIFilter attributes]会返回filter详细信息

下面是我程序返回的一个叫做CISepiaTone滤镜返回的详细信息:

[cpp] view
plain copy

2012-09-18 16:17:09.155 SZFYKJHomeWorkVersion1[2836:f803] {

CIAttributeFilterCategories = (//滤镜所示种类,通常一个滤镜可以属于几种

CICategoryColorEffect, //总类,这只是根据滤镜效果,作用来分类的

CICategoryVideo, //可以用种类名来搜索Fileter;

CICategoryInterlaced,

CICategoryNonSquarePixels,

CICategoryStillImage,

CICategoryBuiltIn

);

CIAttributeFilterDisplayName = "Sepia Tone";

CIAttributeFilterName = CISepiaTone; //滤镜的名称,通过该名称来

//调用滤镜,具体见下面实例

inputImage = { //滤镜使用需要输入的参数,该

CIAttributeClass = CIImage; //参数类型为CIImage。

CIAttributeType = CIAttributeTypeImage;

};

inputIntensity = { //输入强度,参数的名称

CIAttributeClass = NSNumber; //类型

CIAttributeDefault = 1; //默认值

CIAttributeIdentity = 0;

CIAttributeMax = 1; //最大值

CIAttributeMin = 0; //最小值

CIAttributeSliderMax = 1;

CIAttributeSliderMin = 0;

CIAttributeType = CIAttributeTypeScalar;

};

}

这三个我觉得是关键点,前面说过,我觉得CISepiaTone有一大堆兄弟,原来兄弟在这里找,
来:执行以下:

NSLog(@"%@",[CIFilter  filterNamesInCategory:nil]);
哇塞,果然是一大堆:



随便复制一个:查看详细信息:

CIFilter *filter = [CIFilter filterWithName:@"CIWhitePointAdjust"];
NSLog(@"%@",[whiteFilter attributes]);


于是,输出了这么多,

2016-03-10 17:35:08.611 CoreImageDemo[3845:197174] {

"CIAttributeFilterAvailable_Mac" = "10.4";

"CIAttributeFilterAvailable_iOS" = 5;

CIAttributeFilterCategories = (

CICategoryColorAdjustment,

CICategoryVideo,

CICategoryStillImage,

CICategoryInterlaced,

CICategoryNonSquarePixels,

CICategoryBuiltIn

);

CIAttributeFilterDisplayName = "White Point Adjust";

CIAttributeFilterName = CIWhitePointAdjust;

CIAttributeReferenceDocumentation = "http://developer.apple.com/cgi-bin/apple_ref.cgi?apple_ref=//apple_ref/doc/filter/ci/CIWhitePointAdjust";

inputColor = {

CIAttributeClass = CIColor;

CIAttributeDefault = "(1 1 1 1)";

CIAttributeDescription = "A color to use as the white point.";

CIAttributeDisplayName = Color;

CIAttributeIdentity = "(1 1 1 1)";

CIAttributeType = CIAttributeTypeColor;

};

inputImage = {

CIAttributeClass = CIImage;

CIAttributeDescription = "The image to use as an input image. For filters that also use a background image, this is the foreground image.";

CIAttributeDisplayName = Image;

CIAttributeType = CIAttributeTypeImage;

};

}
看看这个,这个就跟学习博客上的图片内容很相近了,对比一下啦
有没有发现这个需要的是不是inputColor(属于CIColor)和inputImage(属于CIImage)两种啊
对比CISepiaTone
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues:kCIInputImageKey,image, @"inputIntensity",@0.8,nil];
那写呗,我的直觉告诉我,inputColor应该也可以写成Key的那种,于是敲了一个kCIInputC出来啦(那出来了我又有一个直觉了,凡是CoreImage自带的类,一般类名以CI开头,有key值,其他没有,所以要用@""形式~)
// 在这里,它需要一个CIColor的对象,那就创建呗,创建对象一般都是CIColor color出来啦,幸亏和UIColor长得一样一样的,随便写两个值,再把对象写给color
CIColor *color = [CIColor colorWithRed:0.5 green:0.1 blue:0.1];
CIFilter *whiteFilter = [CIFilter filterWithName:@"CIWhitePointAdjust" keysAndValues:kCIInputImageKey,image,kCIInputColorKey,color,nil];
其他的都没变,依然是那四步,不知道的看初步学习一吧,这里不说了,这一节的重点就在我从学习博客复制下来的那一块。
原图:



运行结果图:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: