mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2024-10-15 23:23:38 +00:00
updated ScanLine Filter
git-svn-id: svn://qnap.local/TwoTerm/trunk@2011 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
parent
b4679ffc9f
commit
f18c3a6284
@ -11,7 +11,8 @@
|
||||
|
||||
|
||||
@interface ScanLineFilter : CIFilter {
|
||||
NSNumber *inputStrength;
|
||||
NSNumber *inputLighten;
|
||||
NSNumber *inputDarken;
|
||||
CIImage *inputImage;
|
||||
}
|
||||
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user