PDA

View Full Version : Assigning input for filter




mahaboob
Jun 29, 2009, 11:52 PM
Hi,
I can apply almost all filter effects to my graphics except Generator and Gradient effects. I'm applying filters in drawRect: method. This method is calling a function for applying filters. This function checks all the filters in effect stack and assigns input graphics for the input key named "inputImage" and return the output after applying the filters. For those filters (Generator and Gradient) there is no input keys named "inputImage". So how can I assign input graphics? I'm using code in this function is :

-(CIImage*)CIImageResultForEffectStack:(CIImage*)iimage {

NSMutableArray* arr = [self effectStack];

CIImage* result = nil;

CIFilter* tFilter;

JPFilter* tJPFilter;

NSString *key, *classstring;

NSArray *inputKeys;

NSDictionary *attr;

NSEnumerator *enumerator;

int i;
for(i = 0 ; i< [arr count] ; i++)
{
tJPFilter = [ arr objectAtIndex:i];

if([tJPFilter isEnabled])
{
tFilter = [tJPFilter filter];

attr = [tFilter attributes];

inputKeys = [tFilter inputKeys];

enumerator = [inputKeys objectEnumerator];

while ((key = [enumerator nextObject]) != nil)
{
id parameter = [attr objectForKey:key];

if ([parameter isKindOfClass:[NSDictionary class]])
{
classstring = [(NSDictionary *)parameter objectForKey: kCIAttributeClass];

if ([classstring isEqualToString:@"CIImage"] )
{
[tFilter setValue:[self imageMask] forKey:key];
}
}
}

if([inputKeys containsObject:@"inputImage"])
{
if(result!=nil)
[tFilter setValue:result forKey:@"inputImage"];
else
[tFilter setValue:iimage forKey:@"inputImage"];

}
result = [tFilter valueForKey: @"outputImage"];
}
}

return result;
}



mahaboob
Jun 30, 2009, 06:29 AM
Hi,
I managed to solve it.
Now I need to position the effects over the graphics by dragging it.
Now it is coming from one position in the graphics and I can't make any adjustments by dragging it. How can I do it?