Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change brightness, contrast and saturation using sliders #2187

Open
cacdzya opened this issue Jan 24, 2016 · 0 comments
Open

Change brightness, contrast and saturation using sliders #2187

cacdzya opened this issue Jan 24, 2016 · 0 comments

Comments

@cacdzya
Copy link

cacdzya commented Jan 24, 2016

Hi. I'm trying to change brightness, contrast and saturation together to implement using sliders; the code works for me in some images, but in other images my app crashes. When I applied this part of the code:

[filtroSaturacion useNextFrameForImageCapture];
[stillImageSource processImage];

I hope you can help me and thanks four your help. Here I leave my code:

  • (void) inicializarBasicos {

    gpuViewImagen = [[GPUImageView alloc] initWithFrame:copiaViewImagen.frame];

    stillImageSource = [[GPUImagePicture alloc] initWithImage:copiaViewImagen.image];

    filtroBrillo = [[GPUImageBrightnessFilter alloc] init];
    filtroContraste = [[GPUImageContrastFilter alloc] init];
    filtroSaturacion = [[GPUImageSaturationFilter alloc] init];

    [filtroBrillo forceProcessingAtSize:copiaViewImagen.image.size];
    [filtroContraste forceProcessingAtSize:copiaViewImagen.image.size];
    [filtroSaturacion forceProcessingAtSize:copiaViewImagen.image.size];

    [stillImageSource addTarget:filtroBrillo];

    [filtroBrillo addTarget:filtroContraste];
    [filtroContraste addTarget:filtroSaturacion];
    [filtroSaturacion addTarget:gpuViewImagen];

    [_view_total addSubview:gpuViewImagen];

    [_view_total sendSubviewToBack:gpuViewImagen];
    }

  • (IBAction)sliderValueChangedBrillo:(id)sender {

    [filtroSaturacion removeAllTargets];

    [filtroBrillo setBrightness:_slider_brillo.value];

    [filtroSaturacion useNextFrameForImageCapture];

    [stillImageSource processImage];

    UIImage *nearestNeighborImage = [filtroSaturacion imageFromCurrentFramebuffer];

    viewImagenSeleccionada.image = nearestNeighborImage;

    _boton_restaurar_foto.userInteractionEnabled = YES;
    }

  • (IBAction)sliderValueChangedContraste:(id)sender {

    [filtroContraste setContrast:_slider_contraste.value];

    [filtroSaturacion useNextFrameForImageCapture];

    [stillImageSource processImage];

    UIImage *nearestNeighborImage = [filtroSaturacion imageFromCurrentFramebuffer];

    viewImagenSeleccionada.image = nearestNeighborImage;

    _boton_restaurar_foto.userInteractionEnabled = YES;
    }

  • (IBAction)sliderValueChangedSaturacion:(id)sender {

    [filtroSaturacion setSaturation:_slider_saturacion.value];

    [filtroSaturacion useNextFrameForImageCapture];

    [stillImageSource processImage];

    UIImage *nearestNeighborImage = [filtroSaturacion imageFromCurrentFramebuffer];

    viewImagenSeleccionada.image = nearestNeighborImage;

    _boton_restaurar_foto.userInteractionEnabled = YES;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant