1// 2// PRCGrayscale.m 3// PRICE 4// Grayscale Conversion Controller 5// 6// Created by Riccardo Mottola on Tue Jan 16 2007. 7// Copyright (c) 2007-2010 Carduus. All rights reserved. 8// 9// This application is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 10// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 11 12#import "PRCGrayscale.h" 13#import "PRGrayscaleFilter.h" 14 15@implementation PRCGrayscale 16 17- (id)init 18{ 19 if ((self = [super init])) 20 { 21 filter = [[PRGrayscaleFilter alloc] init]; 22 } 23 return self; 24} 25 26- (IBAction)showFilter:(id)sender 27{ 28 [super showFilter:sender]; 29 30 if (!grayWindow) 31 [NSBundle loadNibNamed:@"Grayscale" owner:self]; 32 [grayWindow makeKeyAndOrderFront:nil]; 33 34 [self parametersChanged:self]; 35} 36 37- (NSArray *)encodeParameters 38{ 39 NSArray *parameters; 40 int index; 41 int method; 42 43 index = [methodChoice indexOfSelectedItem]; 44 if (index == 0) 45 method = METHOD_AVERAGE; 46 else if (index == 1) 47 method = METHOD_LUMINANCE; 48 else 49 method = -1; 50 51 /* encode parameters */ 52 parameters = [NSArray arrayWithObjects: 53 [NSNumber numberWithInt:method], 54 nil]; 55 56 return parameters; 57} 58 59- (void)closeFilterPanel 60{ 61 [grayWindow performClose:nil]; 62} 63 64 65 66@end 67