updated ScanLine Filter

git-svn-id: svn://qnap.local/TwoTerm/trunk@2011 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
Kelvin Sherlock 2011-02-03 02:36:36 +00:00
parent b4679ffc9f
commit f18c3a6284
2 changed files with 25 additions and 9 deletions

View File

@ -11,7 +11,8 @@
@interface ScanLineFilter : CIFilter {
NSNumber *inputStrength;
NSNumber *inputLighten;
NSNumber *inputDarken;
CIImage *inputImage;
}

View File

@ -47,10 +47,20 @@ static CIKernel *_kernel = nil;
[NSNumber numberWithDouble: 0.00], kCIAttributeMax,
[NSNumber numberWithDouble: 0.00], kCIAttributeSliderMin,
[NSNumber numberWithDouble: 1.00], kCIAttributeSliderMax,
[NSNumber numberWithDouble: 0.40], kCIAttributeDefault,
[NSNumber numberWithDouble: 0.00], kCIAttributeDefault,
[NSNumber numberWithDouble: 0.00], kCIAttributeIdentity,
kCIAttributeTypeDistance, kCIAttributeType,
nil], @"inputStrength",
nil], @"inputLighten",
[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithDouble: 0.00], kCIAttributeMin,
[NSNumber numberWithDouble: 0.00], kCIAttributeMax,
[NSNumber numberWithDouble: 0.00], kCIAttributeSliderMin,
[NSNumber numberWithDouble: 1.00], kCIAttributeSliderMax,
[NSNumber numberWithDouble: 0.80], kCIAttributeDefault,
[NSNumber numberWithDouble: 0.00], kCIAttributeIdentity,
kCIAttributeTypeDistance, kCIAttributeType,
nil], @"inputDarken",
nil];
}
@ -59,16 +69,21 @@ static CIKernel *_kernel = nil;
// called when setting up for fragment program and also calls fragment program
- (CIImage *)outputImage
{
float strength;
float l, d;
CISampler *src;
src = [CISampler samplerWithImage:inputImage];
src = [CISampler samplerWithImage: inputImage];
strength = [inputStrength floatValue];
if (strength < 0) strength = 0;
if (strength > 1.0) strength = 1.0;
l = [inputLighten floatValue];
d = [inputDarken floatValue];
return [self apply: _kernel, src, [NSNumber numberWithFloat: strength], nil];
if (l < 0) l = 0;
if (l > 1.0) l = 1.0;
if (d < 0) d = 0;
if (d > 1.0) d = 1.0;
return [self apply: _kernel, src, [NSNumber numberWithFloat: l], [NSNumber numberWithFloat: d], nil];
}