嗨,我正在使用GPUImagefilters在图像上应用亮度。但是它不起作用。我在哪里都找不到这个问题。我的代码是这样的
- (void)viewDidLoad
{
self.slider.hidden=YES;
slider.minimumValue = 0.0;
slider.maximumValue = 1.0;
slider.value = 0.1;
}
- (IBAction)brightnessClicked:(id)sender
{
self.slider.hidden=NO;
}
- (IBAction)sliderMoved:(id)sender
{
image_p=[[GPUImagePicture alloc]initWithImage:image3];
GPUImageBrightnessFilter *filter1 = [[GPUImageBrightnessFilter alloc] init];
[image_p addTarget:filter1];
[image_p processImage];
[(GPUImageBrightnessFilter *)filter setBrightness:[(UISlider *)sender value]];
// UIImageWriteToSavedPhotosAlbum([filter1 imageFromCurrentlyProcessedOutput], self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
//self.thirdImgView.image = [image3 brightness:(1+value-0.5)];
// self.thirdImgView.image = ;
}
如果无法让GPUImagefilters告诉我任何其他方式。我尝试了更多方式,但是它不起作用,所以请任何人建议我该怎么做。
最佳答案
试试这些
-(void)viewDidLoad
{
[sliderChange setMinimumValue:-0.5];
[sliderChange setMaximumValue:0.5];
[sliderChange setValue:0.0];
brightnessFilter = [[GPUImageBrightnessFilter alloc] init];
}
-(IBAction)upDateSliderValue:(id)sender
{
GPUImagePicture *fx_image;
fx_image = [[GPUImagePicture alloc] initWithImage:originalImage];
[brightnessFilter setBrightness:self.sliderChange.value];
[fx_image addTarget:brightnessFilter];
[fx_image processImage];
UIImage *final_image = [brightnessFilter imageFromCurrentlyProcessedOutput];
self.selectedImageView.image = final_image;
}