您好我正在使用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告诉我任何其他方式。我尝试了更多的方式,但它不起作用所以请任何人建议我如何做到这一点。感谢任何帮助。
答案 0 :(得分:2)
试试这些
-(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;
}
答案 1 :(得分:0)
- (UIImage *)getNewImageFromImage:(UIImage *)image withBrightness:(CGFloat)brightnessValue
{
// pass the image through a brightness filter
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:image];
GPUImageBrightnessFilter *brightnessFilter = [[GPUImageBrightnessFilter alloc] init];
[brightnessFilter setBrightness:brightnessValue];
[blurFilter addTarget:brightnessFilter];
[stillImageSource processImage];
return [brightnessFilter imageFromCurrentlyProcessedOutputWithOrientation:UIImageOrientationUp];
}
要使其比默认值更暗,您必须传递负值。