Apologies for the cross posting from quartz-dev. But it seems these days that 
it is hard to work out which forum, lists/devforum and then which of the 
discussions to then post.

I've been playing with creating a core image filter for OS X. I've got simple 
chroma key filter working as I would like, except for two issues. The first 
issue is a compile warning which if I ignore doesn't stop the filter from 
working. But I'd still like it resolved even if it is only for me to understand 
what is going on, or perhaps that it highlights something that I'm doing wrong 
but non-critical.

The filter is defined like so in the header:

@interface YVSChromaKeyFilter : CIFilter

Because I'm currently using the filter in a simple stand alone command line 
tool and I want to keep this option as a use for the filter I'm not packaging 
the filter up into a image unit as the recommended way to distribute image 
filters by apple so I'm using the alternate method which uses the 
registerFilterName method called from the filter's class initialize method:

@implementation YVSChromaKeyFilter

+(void)initialize
{
   if (self == [YVSChromaKeyFilter class])
   {
       NSArray *kernels = [CIKernel kernelsWithString:YVSChromaKeyFilterString];
       chromaKeyKernel = kernels[0];
       [CIFilter registerFilterName:@"YVSChromaKeyFilter"
                        constructor:(id<CIFilterConstructor>)self
                    classAttributes:@{
           kCIAttributeFilterDisplayName : @"Simple Chroma Key.",
            kCIAttributeFilterCategories : @[
                  kCICategoryColorAdjustment, kCICategoryVideo,
                  kCICategoryStillImage, kCICategoryInterlaced,
                  kCICategoryNonSquarePixels]
                                    }
        ];
   }
}

+(CIFilter *)filterWithName:(NSString *)name
{
   CIFilter  *filter;
   filter = [[YVSChromaKeyFilter alloc] init];
   return filter;
}

Note the cast in the constructor: option of the registerFilterName method, this 
was done to remove the compiler warning but really should not be there. I tried 
adding the protocol to the YVSChromaKeyFilter interface but that made no 
difference. My filter gets created correctly when I set things up as above and 
do:

CIFilter *filter =  [CIFilter filterWithName:@"YVSChromaKeyFilter"];

Now the protocol CIFilterConstructor interface is as follows:

@protocol CIFilterConstructor
- (CIFilter *)filterWithName:(NSString *)name;
@end

Which confuses me since I have to implement a class method filterWithName not 
an object method.

As I said, the filter works and does what I want but I'm missing something here 
that I'd like clarified and hopefully resolve things in a way that the ugly 
cast can be removed.

I'll put the second issue into a new e-mail as I think putting it here now will 
just add confusion.

Kevin

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to