Changeset 1870


Ignore:
Timestamp:
Nov 3, 2007 11:59:53 PM (7 years ago)
Author:
sam
Message:
  • Add cucul_get_dither_brightness(), _gamma() and _contrast(). There is no reason to keep a copy of them in the calling program.
  • Deprecate cucul_set_dither_invert(). Inverting a dither's colours is now done by setting a negative gamma value.
Location:
libcaca/trunk/cucul
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/cucul.h

    r1853 r1870  
    209209                             unsigned int b[], unsigned int a[]); 
    210210int cucul_set_dither_brightness(cucul_dither_t *, float); 
     211float cucul_get_dither_brightness(cucul_dither_t *); 
    211212int cucul_set_dither_gamma(cucul_dither_t *, float); 
     213float cucul_get_dither_gamma(cucul_dither_t *); 
    212214int cucul_set_dither_contrast(cucul_dither_t *, float); 
    213 int cucul_set_dither_invert(cucul_dither_t *, int); 
     215float cucul_get_dither_contrast(cucul_dither_t *); 
    214216int cucul_set_dither_antialias(cucul_dither_t *, char const *); 
    215217char const * const * cucul_get_dither_antialias_list(cucul_dither_t const *); 
     
    292294                                         char const *) CUCUL_DEPRECATED; 
    293295    int cucul_rotate(cucul_canvas_t *) CUCUL_DEPRECATED; 
     296    int cucul_set_dither_invert(cucul_dither_t *, int) CUCUL_DEPRECATED; 
    294297#   define CUCUL_COLOR_BLACK CUCUL_BLACK 
    295298#   define CUCUL_COLOR_BLUE CUCUL_BLUE 
  • libcaca/trunk/cucul/dither.c

    r1833 r1870  
    419419} 
    420420 
     421/** \brief Get the brightness of a dither object. 
     422 * 
     423 *  Get the brightness of the given dither object. 
     424 * 
     425 *  This function never fails. 
     426 * 
     427 *  \param d Dither object. 
     428 *  \return Brightness value. 
     429 */ 
     430float cucul_get_dither_brightness(cucul_dither_t *d) 
     431{ 
     432    /* FIXME */ 
     433    return 0.0; 
     434} 
     435 
    421436/** \brief Set the gamma of a dither object. 
    422437 * 
    423  *  Set the gamma of dither. 
     438 *  Set the gamma of the given dither object. A negative value causes 
     439 *  colour inversion. 
    424440 * 
    425441 *  If an error occurs, -1 is returned and \b errno is set accordingly: 
     
    433449{ 
    434450    /* FIXME: we don't need 4096 calls to gammapow(), we could just compute 
    435      * 128 of them and do linear interpolation for the rest. This will 
     451     * a few of them and do linear interpolation for the rest. This will 
    436452     * probably speed up things a lot. */ 
    437453    int i; 
    438454 
    439     if(gamma <= 0.0) 
     455    if(gamma < 0.0) 
     456    { 
     457        d->invert = 1; 
     458        gamma = -gamma; 
     459    } 
     460    else if(gamma == 0.0) 
    440461    { 
    441462        seterrno(EINVAL); 
     
    451472} 
    452473 
    453 /** \brief Invert colors of dither 
    454  * 
    455  *  Invert colors of dither. 
     474/** \brief Get the gamma of a dither object. 
     475 * 
     476 *  Get the gamma of the given dither object. 
    456477 * 
    457478 *  This function never fails. 
    458479 * 
    459480 *  \param d Dither object. 
    460  *  \param value 0 for normal behaviour, 1 for invert 
    461  *  \return This function always returns 0. 
    462  */ 
    463 int cucul_set_dither_invert(cucul_dither_t *d, int value) 
    464 { 
    465     d->invert = value ? 1 : 0; 
    466  
    467     return 0; 
     481 *  \return Gamma value. 
     482 */ 
     483float cucul_get_dither_gamma(cucul_dither_t *d) 
     484{ 
     485    return d->gamma; 
    468486} 
    469487 
  • libcaca/trunk/cucul/legacy.c

    r1788 r1870  
    6464 
    6565/* 
     66 * Functions from dither.c 
     67 */ 
     68int cucul_set_dither_invert(cucul_dither_t *d, int value) 
     69{ 
     70    float gamma = cucul_get_dither_gamma(d); 
     71 
     72    if(gamma * (value ? -1 : 1) < 0) 
     73        cucul_set_dither_gamma(d, -gamma); 
     74 
     75    return 0; 
     76} 
     77 
     78/* 
    6679 * Functions from import.c 
    6780 */ 
Note: See TracChangeset for help on using the changeset viewer.