And here is an example which takes the current bitmap layer and converts it to grayscale using
CoreImage, using Objective-C.
A version of this, along with the Xcode project is available in
SampleAcornPlugins.zip∞
// the header file
#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
#import "ACPlugin.h"
@interface ACGrayscalePlugin : NSObject <ACPlugin> {
}
@end
// the implementation
#import "ACGrayscalePlugin.h"
@implementation ACGrayscalePlugin
+ (id) plugin {
return [[[self alloc] init] autorelease];
}
- (void) willRegister:(id<ACPluginManager>)pluginManager {
[pluginManager addFilterMenuTitle:@"Grayscale"
withSuperMenuTitle:@"Color"
target:self
action:@selector(convert:userObject:)
keyEquivalent:@""
keyEquivalentModifierMask:0
userObject:nil];
}
- (CIImage*) convert:(CIImage*)image userObject:(id)uo {
#pragma unused (uo)
CIFilter *filter = [CIFilter filterWithName: @"CIColorMonochrome" keysAndValues: @"inputImage", image, nil];
CIColor *color = [CIColor colorWithRed:0.5f green:0.5f blue:0.5f];
[filter setDefaults];
[filter setValue:color forKey:@"inputColor"];
[filter setValue:[NSNumber numberWithFloat:1] forKey:@"inputIntensity"];
return [filter valueForKey: @"outputImage"];
}
- (void) didRegister {
}
@end
Back to
AcornPlugins