Re: Binding to CoreImage?
Re: Binding to CoreImage?
- Subject: Re: Binding to CoreImage?
- From: Colin Cornaby <email@hidden>
- Date: Fri, 21 Oct 2005 16:27:46 -0700
The redrawn image is unaltered, and when I get a description the
filter is still at their default value. I don't actually have
observer code present yet, I just have a button set up to manually
redraw. On the manual redraw, it prints out a description of the
filter it's trying to draw. I throw the slider around and I always
get for the description:
2005-10-21 15:59:23.268 Catalyst[7243] {CIHueAdjust {inputAngle = 0;
inputImage = {CIImage [0 0 22 26]}; }}
2005-10-21 15:59:23.438 Catalyst[7243] {CIHueAdjust {inputAngle = 0;
inputImage = {CIImage [0 0 22 26]}; }}
2005-10-21 15:59:23.640 Catalyst[7243] {CIHueAdjust {inputAngle = 0;
inputImage = {CIImage [0 0 22 26]}; }}
2005-10-21 15:59:24.348 Catalyst[7243] {CIHueAdjust {inputAngle = 0;
inputImage = {CIImage [0 0 22 26]}; }}
2005-10-21 15:59:24.528 Catalyst[7243] {CIHueAdjust {inputAngle = 0;
inputImage = {CIImage [0 0 22 26]}; }}
2005-10-21 15:59:24.708 Catalyst[7243] {CIHueAdjust {inputAngle = 0;
inputImage = {CIImage [0 0 22 26]}; }}
The key that I am trying to bind to is "inputAngle" but inputAngle is
never changing. The binding code with the variables substituted in is
something like:
[newSlider bind:@"value" toObject:(CIHueAdjust here)
withKeyPath:@"inputAngle" options:bindingOptions];
-Colin
On Oct 21, 2005, at 3:18 PM, Troy Stephens wrote:
This looks like it should work as written. I have some very
similar code in a project that works fine. In what sense is this
broken? Is it a matter of your image display not refreshing when
you move one of the sliders, or are you seeing the corresponding
attribute unchanged when you read its value back from the filter?
One thing to be sure to do (which might be in code you elided
below) is set the min and max values of the slider to be compatible
with the attribute's recommended range (kCIAttributeSliderMin to
kCIAttributeSliderMax).
Troy
On Oct 21, 2005, at 3:01 PM, Colin Cornaby wrote:
Thanks for the help!
I'm trying to create the binding progmatically though and am
running into trouble. This is probably going to be more a pure
bindings question rather than CoreImage question. I'm create an
interface on the fly for a filter and trying to bind a control
I've just created on the fly to a given filter. I just have a loop
that goes through and creates the controls.
NSMutableDictionary *bindingOptions = [NSMutableDictionary
dictionary];
[bindingOptions setObject:[NSNumber numberWithBool:YES]
forKey:NSValidatesImmediatelyBindingOption];
[bindingOptions setObject:[NSNumber numberWithBool:YES]
forKey:NSContinuouslyUpdatesValueBindingOption];
for(i;i<[[aFilter inputKeys] count];i++)
{
...
if([[[[aFilter attributes] objectForKey:[[aFilter inputKeys]
objectAtIndex:i]] objectForKey:kCIAttributeClass]
isEqualToString:@"NSNumber"])
{
NSSlider *newSlider = [[NSSlider alloc] init];
...
[newSlider bind:@"value" toObject: aFilter withKeyPath:
[[aFilter inputKeys] objectAtIndex:i] options:bindingOptions];
}
}
This is supposed to bind the control to the input value of the
filter, but it's not working. I was going over the code with
someone this morning and they mentioned something about how the
control value is bound to the input value, but the input value
isn't bound to the control value? Anyway, he wasn't up on his
binding code and this is the first time I've tried to do it
progmatically.
Is there something simple I missed with this? The filters value
never changes when I move the slider. Thanks for the observer code
clarification though. I think there was some confusion on that
before.
-Colin
On Oct 21, 2005, at 1:27 PM, Troy Stephens wrote:
On Oct 20, 2005, at 11:58 PM, Colin Cornaby wrote:
Has anyone tried binding to a CIFilter? Anyone have any success?
Doesn't look like binding to the attributes will work too well
because that won't actually render it. I just have some controls
on the screen that I want to progmatically bind.
Has anyone ever played with this? Google search found nothing.
See
http://developer.apple.com/samplecode/Reducer/Reducer.html
for one example. Some of Reducer's UI elements have their values
bound directly to CIFilter properties -- for example, the sharpen
"Intensity" slider is bound to a CIUnsharpMaskFilter's
"inputIntensity" attribute.
To receive notification that the output image needs to be re-
rendered when one of these attributes is changed, the
ImageReducer object uses KVO to add itself as an observer of the
same attributes:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)
object change:(NSDictionary *)change context:(void *)context {
if (object == unsharpMaskFilter || object == shadow) {
[self updateOutputImage];
}
}
- init {
...
[unsharpMaskFilter addObserver:self
forKeyPath:@"inputIntensity" options:0 context:NULL];
[unsharpMaskFilter addObserver:self
forKeyPath:@"inputRadius" options:0 context:NULL];
...
Hope this helps!
--
Troy Stephens
Cocoa Frameworks
Apple Computer, Inc.
--
Troy Stephens
Cocoa Frameworks
Apple Computer, Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden