[cairo] How to brighten image, maintaining contrast?

Bill Spitzak spitzak at gmail.com
Thu Jun 13 13:36:35 PDT 2013


Try using the image itself as a source.

Stuart Axon wrote:
> I've been trying out some of the lighten some images, is there a way to 
> brighten an image, but maintain contrast .. so far I've played LIGHTEN, 
> HARD_LIGHT and SOFT_LIGHT - but images end up looking washed out.. any 
> idea of a better approach ?
>  
> 
> S++
> 
> 
> Code is pretty simple at the moment;
> 
> 
>         LIGHTEN_ALPHA = 0.25
>         LIGHTEN_OPERATOR = cairo.constants.OPERATOR_LIGHTEN
> 
>         width = source_surface.get_width()
>         height = source_surface.get_height()
> 
> 
>         lightened = cairo.ImageSurface( cairo.constants.FORMAT_ARGB32, 
> width, height )
>         with cairo.Context( lightened ) as cr:
>             cr.set_source_surface(source_surface)
>             cr.paint()
> 
>             cr.set_operator( LIGHTEN_OPERATOR )
>             cr.set_source_rgba(1, 1, 1, LIGHTEN_ALPHA)
>             cr.paint()
> 
> 


More information about the cairo mailing list