我想对在我的应用程序中捕获的照片应用滤镜效果。我需要3个按钮来调用这些效果(即一个用于黑白,一个用于深褐色,一个用于复古)。所以这是我的问题。当我的图片被保存时,你会在下面看到一个代码。你会在那里看到"img = img e1“。这会将图像保存为黑白图像。如果我做"img = img e2“,它将是深褐色。如果我希望这种效果是永久的,我的代码就能正常工作。问题是,我需要按钮在不同的e数字之间切换,如果这有意义的话。如果没有很好的解释,我很抱歉。
- (void)captureEnded:(CameraView *)camView {
NSLog(@"%f, %f", [camView capturedImage].size.width, [camView capturedImage].size.height)
UIImage *img = [camView capturedImage];
img = [img e1];
img = [UIImage imageWithCGImage:[ self rotateImage:img angle:90 ].CGImage
scale:1.0 orientation: UIImageOrientationUp];
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);发布于 2013-03-25 02:27:44
你可以声明
UIImage *img;在头.h文件和主类中,编写三个按钮动作
-(IBAction) nbutton1{img = img e1;
}
-(IBAction) nbutton2{img = img e2;
}
-(IBAction) nbutton3{img = img e3;
}
发布于 2013-03-25 02:40:55
方法名称数组
NSArray *methodArray = [NSArray arrayWithObjects:@"e1", @"e2", @"e3", nil];使用数组中使用的名称声明方法
- (void)e1
{
// Code for Black & White effect
}
- (void)e2
{
// Code for Sepia effect
}
- (void)e3
{
// Code for Vignet effect
}现在使用以下代码调用具有数组对象的方法
[self performSelector:NSSelectorFromString([methodArray objectAtIndex:0])]; // call to method e1
[self performSelector:NSSelectorFromString([methodArray objectAtIndex:1])]; // call to method e2
[self performSelector:NSSelectorFromString([methodArray objectAtIndex:2])]; // call to method e3https://stackoverflow.com/questions/15602121
复制相似问题