Changeset 734


Ignore:
Timestamp:
Apr 10, 2006, 10:02:38 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Renamed *bitmap to *dither. Ben ouais connard, je fais ce que je veux.
Location:
libcaca/trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/bitmap.c

    r733 r734  
    1515 *  \brief Bitmap blitting
    1616 *
    17  *  This file contains bitmap blitting functions.
     17 *  This file contains bitmap dithering functions.
    1818 */
    1919
     
    114114};
    115115
    116 struct cucul_bitmap
     116struct cucul_dither
    117117{
    118118    int bpp, has_palette, has_alpha;
     
    121121    int rright, gright, bright, aright;
    122122    int rleft, gleft, bleft, aleft;
    123     void (*get_hsv)(struct cucul_bitmap *, char *, int, int);
     123    void (*get_hsv)(struct cucul_dither *, char *, int, int);
    124124    int red[256], green[256], blue[256], alpha[256];
    125125    float gamma;
     
    166166static float gammapow(float x, float y);
    167167
    168 static void get_rgba_default(struct cucul_bitmap const *, uint8_t *, int, int,
     168static void get_rgba_default(struct cucul_dither const *, uint8_t *, int, int,
    169169                             unsigned int *);
    170170
     
    231231
    232232/**
    233  * \brief Create an internal bitmap object.
    234  *
    235  * Create a bitmap structure from its coordinates (depth, width, height and
     233 * \brief Create an internal dither object.
     234 *
     235 * Create a dither structure from its coordinates (depth, width, height and
    236236 * pitch) and pixel mask values. If the depth is 8 bits per pixel, the mask
    237237 * values are ignored and the colour palette should be set using the
    238  * cucul_set_bitmap_palette() function. For depths greater than 8 bits per
     238 * cucul_set_dither_palette() function. For depths greater than 8 bits per
    239239 * pixel, a zero alpha mask causes the alpha values to be ignored.
    240240 *
     
    247247 * \param bmask Bitmask for blue values.
    248248 * \param amask Bitmask for alpha values.
    249  * \return Bitmap object, or NULL upon error.
    250  */
    251 struct cucul_bitmap *cucul_create_bitmap(unsigned int bpp, unsigned int w,
     249 * \return Dither object, or NULL upon error.
     250 */
     251struct cucul_dither *cucul_create_dither(unsigned int bpp, unsigned int w,
    252252                                         unsigned int h, unsigned int pitch,
    253253                                         unsigned int rmask, unsigned int gmask,
    254254                                         unsigned int bmask, unsigned int amask)
    255255{
    256     struct cucul_bitmap *bitmap;
     256    struct cucul_dither *d;
    257257    int i;
    258258
     
    261261        return NULL;
    262262
    263     bitmap = malloc(sizeof(struct cucul_bitmap));
    264     if(!bitmap)
     263    d = malloc(sizeof(struct cucul_dither));
     264    if(!d)
    265265        return NULL;
    266266
    267     bitmap->bpp = bpp;
    268     bitmap->has_palette = 0;
    269     bitmap->has_alpha = amask ? 1 : 0;
    270 
    271     bitmap->w = w;
    272     bitmap->h = h;
    273     bitmap->pitch = pitch;
    274 
    275     bitmap->rmask = rmask;
    276     bitmap->gmask = gmask;
    277     bitmap->bmask = bmask;
    278     bitmap->amask = amask;
     267    d->bpp = bpp;
     268    d->has_palette = 0;
     269    d->has_alpha = amask ? 1 : 0;
     270
     271    d->w = w;
     272    d->h = h;
     273    d->pitch = pitch;
     274
     275    d->rmask = rmask;
     276    d->gmask = gmask;
     277    d->bmask = bmask;
     278    d->amask = amask;
    279279
    280280    /* Load bitmasks */
    281281    if(rmask || gmask || bmask || amask)
    282282    {
    283         mask2shift(rmask, &bitmap->rright, &bitmap->rleft);
    284         mask2shift(gmask, &bitmap->gright, &bitmap->gleft);
    285         mask2shift(bmask, &bitmap->bright, &bitmap->bleft);
    286         mask2shift(amask, &bitmap->aright, &bitmap->aleft);
     283        mask2shift(rmask, &d->rright, &d->rleft);
     284        mask2shift(gmask, &d->gright, &d->gleft);
     285        mask2shift(bmask, &d->bright, &d->bleft);
     286        mask2shift(amask, &d->aright, &d->aleft);
    287287    }
    288288
     
    290290    if(bpp == 8)
    291291    {
    292         bitmap->has_palette = 1;
    293         bitmap->has_alpha = 0;
     292        d->has_palette = 1;
     293        d->has_alpha = 0;
    294294        for(i = 0; i < 256; i++)
    295295        {
    296             bitmap->red[i] = i * 0xfff / 256;
    297             bitmap->green[i] = i * 0xfff / 256;
    298             bitmap->blue[i] = i * 0xfff / 256;
     296            d->red[i] = i * 0xfff / 256;
     297            d->green[i] = i * 0xfff / 256;
     298            d->blue[i] = i * 0xfff / 256;
    299299        }
    300300    }
    301301
    302302    /* Default features */
    303     bitmap->invert = 0;
    304     bitmap->antialias = 1;
     303    d->invert = 0;
     304    d->antialias = 1;
    305305
    306306    /* Default gamma value */
    307307    for(i = 0; i < 4096; i++)
    308         bitmap->gammatab[i] = i;
     308        d->gammatab[i] = i;
    309309
    310310    /* Default colour mode */
    311     bitmap->color_mode = COLOR_MODE_FULL16;
     311    d->color_mode = COLOR_MODE_FULL16;
    312312
    313313    /* Default character set */
    314     bitmap->glyphs = ascii_glyphs;
    315     bitmap->glyph_count = sizeof(ascii_glyphs) / sizeof(*ascii_glyphs);
     314    d->glyphs = ascii_glyphs;
     315    d->glyph_count = sizeof(ascii_glyphs) / sizeof(*ascii_glyphs);
    316316
    317317    /* Default dithering mode */
    318     bitmap->init_dither = init_fstein_dither;
    319     bitmap->get_dither = get_fstein_dither;
    320     bitmap->increment_dither = increment_fstein_dither;
    321 
    322     return bitmap;
    323 }
    324 
    325 /**
    326  * \brief Set the palette of an 8bpp bitmap object.
     318    d->init_dither = init_fstein_dither;
     319    d->get_dither = get_fstein_dither;
     320    d->increment_dither = increment_fstein_dither;
     321
     322    return d;
     323}
     324
     325/**
     326 * \brief Set the palette of an 8bpp dither object.
    327327 *
    328328 * Set the palette of an 8 bits per pixel bitmap. Values should be between
    329329 * 0 and 4095 (0xfff).
    330330 *
    331  * \param bitmap Bitmap object.
     331 * \param dither Dither object.
    332332 * \param red Array of 256 red values.
    333333 * \param green Array of 256 green values.
     
    335335 * \param alpha Array of 256 alpha values.
    336336 */
    337 void cucul_set_bitmap_palette(struct cucul_bitmap *bitmap,
     337void cucul_set_dither_palette(struct cucul_dither *d,
    338338                              unsigned int red[], unsigned int green[],
    339339                              unsigned int blue[], unsigned int alpha[])
     
    341341    int i, has_alpha = 0;
    342342
    343     if(bitmap->bpp != 8)
     343    if(d->bpp != 8)
    344344        return;
    345345
     
    351351           alpha[i] >= 0 && alpha[i] < 0x1000)
    352352        {
    353             bitmap->red[i] = red[i];
    354             bitmap->green[i] = green[i];
    355             bitmap->blue[i] = blue[i];
     353            d->red[i] = red[i];
     354            d->green[i] = green[i];
     355            d->blue[i] = blue[i];
    356356            if(alpha[i])
    357357            {
    358                 bitmap->alpha[i] = alpha[i];
     358                d->alpha[i] = alpha[i];
    359359                has_alpha = 1;
    360360            }
     
    362362    }
    363363
    364     bitmap->has_alpha = has_alpha;
    365 }
    366 
    367 /**
    368  * \brief Set the brightness of a bitmap object.
    369  *
    370  * Set the brightness of bitmap.
    371  *
    372  * \param bitmap Bitmap object.
     364    d->has_alpha = has_alpha;
     365}
     366
     367/**
     368 * \brief Set the brightness of a dither object.
     369 *
     370 * Set the brightness of dither.
     371 *
     372 * \param dither Dither object.
    373373 * \param brightness brightness value.
    374374 */
    375 void cucul_set_bitmap_brightness(struct cucul_bitmap *bitmap, float brightness)
     375void cucul_set_dither_brightness(struct cucul_dither *d, float brightness)
    376376{
    377377    /* FIXME */
     
    379379
    380380/**
    381  * \brief Set the gamma of a bitmap object.
    382  *
    383  * Set the gamma of bitmap.
    384  *
    385  * \param bitmap Bitmap object.
     381 * \brief Set the gamma of a dither object.
     382 *
     383 * Set the gamma of dither.
     384 *
     385 * \param dither Dither object.
    386386 * \param gamma Gamma value.
    387387 */
    388 void cucul_set_bitmap_gamma(struct cucul_bitmap *bitmap, float gamma)
     388void cucul_set_dither_gamma(struct cucul_dither *d, float gamma)
    389389{
    390390    /* FIXME: we don't need 4096 calls to gammapow(), we can just compute
     
    396396        return;
    397397
    398     bitmap->gamma = gamma;
     398    d->gamma = gamma;
    399399
    400400    for(i = 0; i < 4096; i++)
    401         bitmap->gammatab[i] = 4096.0 * gammapow((float)i / 4096.0, 1.0 / gamma);
    402 }
    403 
    404 /**
    405  * \brief Invert colors of bitmap
    406  *
    407  * Invert colors of bitmap
    408  *
    409  * \param bitmap Bitmap object.
     401        d->gammatab[i] = 4096.0 * gammapow((float)i / 4096.0, 1.0 / gamma);
     402}
     403
     404/**
     405 * \brief Invert colors of dither
     406 *
     407 * Invert colors of dither
     408 *
     409 * \param dither Dither object.
    410410 * \param value 0 for normal behaviour, 1 for invert
    411411 */
    412 void cucul_set_bitmap_invert(struct cucul_bitmap *bitmap, int value)
    413 {
    414     bitmap->invert = value ? 1 : 0;
    415 }
    416 
    417 /**
    418  * \brief Set the contrast of a bitmap object.
    419  *
    420  * Set the contrast of bitmap.
    421  *
    422  * \param bitmap Bitmap object.
     412void cucul_set_dither_invert(struct cucul_dither *d, int value)
     413{
     414    d->invert = value ? 1 : 0;
     415}
     416
     417/**
     418 * \brief Set the contrast of a dither object.
     419 *
     420 * Set the contrast of dither.
     421 *
     422 * \param dither Dither object.
    423423 * \param contrast contrast value.
    424424 */
    425 void cucul_set_bitmap_contrast(struct cucul_bitmap *bitmap, float contrast)
     425void cucul_set_dither_contrast(struct cucul_dither *d, float contrast)
    426426{
    427427    /* FIXME */
     
    429429
    430430/**
    431  * \brief Set bitmap antialiasing
    432  *
    433  * Tell the renderer whether to antialias the bitmap. Antialiasing smoothen
     431 * \brief Set dither antialiasing
     432 *
     433 * Tell the renderer whether to antialias the dither. Antialiasing smoothen
    434434 * the rendered image and avoids the commonly seen staircase effect.
    435435 *
     
    439439 *     value.
    440440 *
    441  * \param bitmap Bitmap object.
     441 * \param dither Dither object.
    442442 * \param str A string describing the antialiasing method that will be used
    443  *        for the bitmap rendering.
    444  */
    445 void cucul_set_bitmap_antialias(struct cucul_bitmap *bitmap, char const *str)
     443 *        for the dithering.
     444 */
     445void cucul_set_dither_antialias(struct cucul_dither *d, char const *str)
    446446{
    447447    if(!strcasecmp(str, "none"))
    448         bitmap->antialias = 0;
     448        d->antialias = 0;
    449449    else /* "prefilter" is the default */
    450         bitmap->antialias = 1;
     450        d->antialias = 1;
    451451}
    452452
     
    454454 * \brief Get available antialiasing methods
    455455 *
    456  * Return a list of available antialiasing methods for a given bitmap. The
     456 * Return a list of available antialiasing methods for a given dither. The
    457457 * list is a NULL-terminated array of strings, interleaving a string
    458458 * containing the internal value for the antialiasing method to be used with
    459  * \e cucul_set_bitmap_antialias(), and a string containing the natural
     459 * \e cucul_set_dither_antialias(), and a string containing the natural
    460460 * language description for that antialiasing method.
    461461 *
    462  * \param bitmap Bitmap object.
     462 * \param dither Dither object.
    463463 * \return An array of strings.
    464464 */
    465465char const * const *
    466     cucul_get_bitmap_antialias_list(struct cucul_bitmap const *bitmap)
     466    cucul_get_dither_antialias_list(struct cucul_dither const *d)
    467467{
    468468    static char const * const list[] =
     
    477477
    478478/**
    479  * \brief Choose colours used for bitmap rendering
     479 * \brief Choose colours used for dithering
    480480 *
    481481 * Tell the renderer which colours should be used to render the
     
    499499 *     background. This is the default value.
    500500 *
    501  * \param bitmap Bitmap object.
     501 * \param dither Dither object.
    502502 * \param str A string describing the colour set that will be used
    503  *        for the bitmap rendering.
    504  */
    505 void cucul_set_bitmap_color(struct cucul_bitmap *bitmap, char const *str)
     503 *        for the dithering.
     504 */
     505void cucul_set_dither_color(struct cucul_dither *d, char const *str)
    506506{
    507507    if(!strcasecmp(str, "mono"))
    508         bitmap->color_mode = COLOR_MODE_MONO;
     508        d->color_mode = COLOR_MODE_MONO;
    509509    else if(!strcasecmp(str, "gray"))
    510         bitmap->color_mode = COLOR_MODE_GRAY;
     510        d->color_mode = COLOR_MODE_GRAY;
    511511    else if(!strcasecmp(str, "8"))
    512         bitmap->color_mode = COLOR_MODE_8;
     512        d->color_mode = COLOR_MODE_8;
    513513    else if(!strcasecmp(str, "16"))
    514         bitmap->color_mode = COLOR_MODE_16;
     514        d->color_mode = COLOR_MODE_16;
    515515    else if(!strcasecmp(str, "fullgray"))
    516         bitmap->color_mode = COLOR_MODE_FULLGRAY;
     516        d->color_mode = COLOR_MODE_FULLGRAY;
    517517    else if(!strcasecmp(str, "full8"))
    518         bitmap->color_mode = COLOR_MODE_FULL8;
     518        d->color_mode = COLOR_MODE_FULL8;
    519519    else /* "full16" is the default */
    520         bitmap->color_mode = COLOR_MODE_FULL16;
     520        d->color_mode = COLOR_MODE_FULL16;
    521521}
    522522
     
    524524 * \brief Get available colour modes
    525525 *
    526  * Return a list of available colour modes for a given bitmap. The list
     526 * Return a list of available colour modes for a given dither. The list
    527527 * is a NULL-terminated array of strings, interleaving a string containing
    528528 * the internal value for the colour mode, to be used with
    529  * \e cucul_set_bitmap_color(), and a string containing the natural
     529 * \e cucul_set_dither_color(), and a string containing the natural
    530530 * language description for that colour mode.
    531531 *
    532  * \param bitmap Bitmap object.
     532 * \param dither Dither object.
    533533 * \return An array of strings.
    534534 */
    535535char const * const *
    536     cucul_get_bitmap_color_list(struct cucul_bitmap const *bitmap)
     536    cucul_get_dither_color_list(struct cucul_dither const *d)
    537537{
    538538    static char const * const list[] =
     
    552552
    553553/**
    554  * \brief Choose characters used for bitmap rendering
     554 * \brief Choose characters used for dithering
    555555 *
    556556 * Tell the renderer which characters should be used to render the
    557  * bitmap. Valid values for \e str are:
     557 * dither. Valid values for \e str are:
    558558 *
    559559 * \li \e "ascii": use only ASCII characters. This is the default value.
     
    566566 *     characters are only found in the Unicode set.
    567567 *
    568  * \param bitmap Bitmap object.
     568 * \param dither Dither object.
    569569 * \param str A string describing the characters that need to be used
    570  *        for the bitmap rendering.
    571  */
    572 void cucul_set_bitmap_charset(struct cucul_bitmap *bitmap, char const *str)
     570 *        for the dithering.
     571 */
     572void cucul_set_dither_charset(struct cucul_dither *d, char const *str)
    573573{
    574574    if(!strcasecmp(str, "shades"))
    575575    {
    576         bitmap->glyphs = shades_glyphs;
    577         bitmap->glyph_count = sizeof(shades_glyphs) / sizeof(*shades_glyphs);
     576        d->glyphs = shades_glyphs;
     577        d->glyph_count = sizeof(shades_glyphs) / sizeof(*shades_glyphs);
    578578    }
    579579    else if(!strcasecmp(str, "blocks"))
    580580    {
    581         bitmap->glyphs = blocks_glyphs;
    582         bitmap->glyph_count = sizeof(blocks_glyphs) / sizeof(*blocks_glyphs);
     581        d->glyphs = blocks_glyphs;
     582        d->glyph_count = sizeof(blocks_glyphs) / sizeof(*blocks_glyphs);
    583583    }
    584584    else /* "ascii" is the default */
    585585    {
    586         bitmap->glyphs = ascii_glyphs;
    587         bitmap->glyph_count = sizeof(ascii_glyphs) / sizeof(*ascii_glyphs);
    588     }
    589 }
    590 
    591 /**
    592  * \brief Get available bitmap character sets
    593  *
    594  * Return a list of available character sets for a given bitmap. The list
     586        d->glyphs = ascii_glyphs;
     587        d->glyph_count = sizeof(ascii_glyphs) / sizeof(*ascii_glyphs);
     588    }
     589}
     590
     591/**
     592 * \brief Get available dither character sets
     593 *
     594 * Return a list of available character sets for a given dither. The list
    595595 * is a NULL-terminated array of strings, interleaving a string containing
    596596 * the internal value for the character set, to be used with
    597  * \e cucul_set_bitmap_charset(), and a string containing the natural
     597 * \e cucul_set_dither_charset(), and a string containing the natural
    598598 * language description for that character set.
    599599 *
    600  * \param bitmap Bitmap object.
     600 * \param dither Dither object.
    601601 * \return An array of strings.
    602602 */
    603603char const * const *
    604     cucul_get_bitmap_charset_list(struct cucul_bitmap const *bitmap)
     604    cucul_get_dither_charset_list(struct cucul_dither const *d)
    605605{
    606606    static char const * const list[] =
     
    616616
    617617/**
    618  * \brief Set bitmap dithering method
    619  *
    620  * Tell the renderer which dithering method should be used to render the
    621  * bitmap. Dithering is necessary because the picture being rendered has
    622  * usually far more colours than the available palette. Valid values for
    623  * \e str are:
     618 * \brief Set dithering method
     619 *
     620 * Tell the renderer which dithering method should be used. Dithering is
     621 * necessary because the picture being rendered has usually far more colours
     622 * than the available palette. Valid values for \e str are:
    624623 *
    625624 * \li \e "none": no dithering is used, the nearest matching colour is used.
     
    635634 * \li \e "fstein": use Floyd-Steinberg dithering. This is the default value.
    636635 *
    637  * \param bitmap Bitmap object.
    638  * \param str A string describing the dithering method that needs to be used
    639  *        for the bitmap rendering.
    640  */
    641 void cucul_set_bitmap_dithering(struct cucul_bitmap *bitmap, char const *str)
     636 * \param dither Dither object.
     637 * \param str A string describing the method that needs to be used
     638 *        for the dithering.
     639 */
     640void cucul_set_dither_mode(struct cucul_dither *d, char const *str)
    642641{
    643642    if(!strcasecmp(str, "none"))
    644643    {
    645         bitmap->init_dither = init_no_dither;
    646         bitmap->get_dither = get_no_dither;
    647         bitmap->increment_dither = increment_no_dither;
     644        d->init_dither = init_no_dither;
     645        d->get_dither = get_no_dither;
     646        d->increment_dither = increment_no_dither;
    648647    }
    649648    else if(!strcasecmp(str, "ordered2"))
    650649    {
    651         bitmap->init_dither = init_ordered2_dither;
    652         bitmap->get_dither = get_ordered2_dither;
    653         bitmap->increment_dither = increment_ordered2_dither;
     650        d->init_dither = init_ordered2_dither;
     651        d->get_dither = get_ordered2_dither;
     652        d->increment_dither = increment_ordered2_dither;
    654653    }
    655654    else if(!strcasecmp(str, "ordered4"))
    656655    {
    657         bitmap->init_dither = init_ordered4_dither;
    658         bitmap->get_dither = get_ordered4_dither;
    659         bitmap->increment_dither = increment_ordered4_dither;
     656        d->init_dither = init_ordered4_dither;
     657        d->get_dither = get_ordered4_dither;
     658        d->increment_dither = increment_ordered4_dither;
    660659    }
    661660    else if(!strcasecmp(str, "ordered4"))
    662661    {
    663         bitmap->init_dither = init_ordered8_dither;
    664         bitmap->get_dither = get_ordered8_dither;
    665         bitmap->increment_dither = increment_ordered8_dither;
     662        d->init_dither = init_ordered8_dither;
     663        d->get_dither = get_ordered8_dither;
     664        d->increment_dither = increment_ordered8_dither;
    666665    }
    667666    else if(!strcasecmp(str, "random"))
    668667    {
    669         bitmap->init_dither = init_random_dither;
    670         bitmap->get_dither = get_random_dither;
    671         bitmap->increment_dither = increment_random_dither;
     668        d->init_dither = init_random_dither;
     669        d->get_dither = get_random_dither;
     670        d->increment_dither = increment_random_dither;
    672671    }
    673672    else /* "fstein" is the default */
    674673    {
    675         bitmap->init_dither = init_fstein_dither;
    676         bitmap->get_dither = get_fstein_dither;
    677         bitmap->increment_dither = increment_fstein_dither;
    678     }
    679 }
    680 
    681 /**
    682  * \brief Get bitmap dithering methods
    683  *
    684  * Return a list of available dithering methods for a given bitmap. The list
     674        d->init_dither = init_fstein_dither;
     675        d->get_dither = get_fstein_dither;
     676        d->increment_dither = increment_fstein_dither;
     677    }
     678}
     679
     680/**
     681 * \brief Get dithering methods
     682 *
     683 * Return a list of available dithering methods for a given dither. The list
    685684 * is a NULL-terminated array of strings, interleaving a string containing
    686685 * the internal value for the dithering method, to be used with
    687  * \e cucul_set_bitmap_dithering(), and a string containing the natural
     686 * \e cucul_set_dither_dithering(), and a string containing the natural
    688687 * language description for that dithering method.
    689688 *
    690  * \param bitmap Bitmap object.
     689 * \param dither Dither object.
    691690 * \return An array of strings.
    692691 */
    693692char const * const *
    694     cucul_get_bitmap_dithering_list(struct cucul_bitmap const *bitmap)
     693    cucul_get_dither_mode_list(struct cucul_dither const *d)
    695694{
    696695    static char const * const list[] =
     
    709708
    710709/**
    711  * \brief Draw a bitmap on the screen.
    712  *
    713  * Draw a bitmap at the given coordinates. The bitmap can be of any size and
     710 * \brief Draw a dither on the screen.
     711 *
     712 * Draw a dither at the given coordinates. The dither can be of any size and
    714713 * will be stretched to the text area.
    715714 *
     
    718717 * \param x2 X coordinate of the lower-right corner of the drawing area.
    719718 * \param y2 Y coordinate of the lower-right corner of the drawing area.
    720  * \param bitmap Bitmap object to be drawn.
     719 * \param dither Dither object to be drawn.
    721720 * \param pixels Bitmap's pixels.
    722721 */
    723 void cucul_draw_bitmap(cucul_t *qq, int x1, int y1, int x2, int y2,
    724                        struct cucul_bitmap const *bitmap, void *pixels)
     722void cucul_dither_bitmap(cucul_t *qq, int x1, int y1, int x2, int y2,
     723                         struct cucul_dither const *d, void *pixels)
    725724{
    726725    int *floyd_steinberg, *fs_r, *fs_g, *fs_b;
     
    729728    unsigned int dchmax;
    730729
    731     if(!bitmap || !pixels)
     730    if(!d || !pixels)
    732731        return;
    733732
    734     w = bitmap->w;
    735     h = bitmap->h;
    736     pitch = bitmap->pitch;
     733    w = d->w;
     734    h = d->h;
     735    pitch = d->pitch;
    737736
    738737    if(x1 > x2)
     
    748747    deltax = x2 - x1 + 1;
    749748    deltay = y2 - y1 + 1;
    750     dchmax = bitmap->glyph_count;
     749    dchmax = d->glyph_count;
    751750
    752751    fs_length = ((int)qq->width <= x2 ? (int)qq->width : x2) + 1;
     
    761760        int remain_r = 0, remain_g = 0, remain_b = 0;
    762761
    763         for(x = x1 > 0 ? x1 : 0, bitmap->init_dither(y);
     762        for(x = x1 > 0 ? x1 : 0, d->init_dither(y);
    764763            x <= x2 && x <= (int)qq->width;
    765764            x++)
     
    778777
    779778        /* First get RGB */
    780         if(bitmap->antialias)
     779        if(d->antialias)
    781780        {
    782781            fromx = (x - x1) * w / deltax;
     
    795794            {
    796795                dots++;
    797                 get_rgba_default(bitmap, pixels, myx, myy, rgba);
     796                get_rgba_default(d, pixels, myx, myy, rgba);
    798797            }
    799798
     
    817816            myy = (fromy + toy) / 2;
    818817
    819             get_rgba_default(bitmap, pixels, myx, myy, rgba);
     818            get_rgba_default(d, pixels, myx, myy, rgba);
    820819        }
    821820
    822         if(bitmap->has_alpha && rgba[3] < 0x800)
     821        if(d->has_alpha && rgba[3] < 0x800)
    823822        {
    824823            remain_r = remain_g = remain_b = 0;
     
    830829
    831830        /* XXX: OMG HAX */
    832         if(bitmap->init_dither == init_fstein_dither)
     831        if(d->init_dither == init_fstein_dither)
    833832        {
    834833            rgba[0] += remain_r;
     
    838837        else
    839838        {
    840             rgba[0] += (bitmap->get_dither() - 0x80) * 4;
    841             rgba[1] += (bitmap->get_dither() - 0x80) * 4;
    842             rgba[2] += (bitmap->get_dither() - 0x80) * 4;
     839            rgba[0] += (d->get_dither() - 0x80) * 4;
     840            rgba[1] += (d->get_dither() - 0x80) * 4;
     841            rgba[2] += (d->get_dither() - 0x80) * 4;
    843842        }
    844843
     
    861860
    862861        /* FIXME: we currently only honour "full16" */
    863         if(bitmap->color_mode == COLOR_MODE_FULL16)
     862        if(d->color_mode == COLOR_MODE_FULL16)
    864863        {
    865864            distmin = INT_MAX;
     
    898897                }
    899898            }
    900             outch = bitmap->glyphs[ch];
     899            outch = d->glyphs[ch];
    901900
    902901            /* XXX: OMG HAX */
    903             if(bitmap->init_dither == init_fstein_dither)
     902            if(d->init_dither == init_fstein_dither)
    904903            {
    905904                error[0] = rgba[0] - (fg_r * ch + bg_r * ((2*dchmax-1) - ch)) / (2*dchmax-1);
     
    921920            else if(ch > (int)(dchmax - 1))
    922921                ch = dchmax - 1;
    923             outch = bitmap->glyphs[ch];
     922            outch = d->glyphs[ch];
    924923
    925924            /* XXX: OMG HAX */
    926             if(bitmap->init_dither == init_fstein_dither)
     925            if(d->init_dither == init_fstein_dither)
    927926            {
    928927                error[0] = rgba[0] - bg_r * ch / (dchmax-1);
     
    933932
    934933        /* XXX: OMG HAX */
    935         if(bitmap->init_dither == init_fstein_dither)
     934        if(d->init_dither == init_fstein_dither)
    936935        {
    937936            remain_r = fs_r[x+1] + 7 * error[0] / 16;
     
    949948        }
    950949
    951         if(bitmap->invert)
     950        if(d->invert)
    952951        {
    953952            outfg = 15 - outfg;
     
    959958        cucul_putstr(qq, x, y, outch);
    960959
    961        bitmap->increment_dither();
     960       d->increment_dither();
    962961    }
    963962        /* end loop */
     
    968967
    969968/**
    970  * \brief Free the memory associated with a bitmap.
    971  *
    972  * Free the memory allocated by cucul_create_bitmap().
    973  *
    974  * \param bitmap Bitmap object.
    975  */
    976 void cucul_free_bitmap(struct cucul_bitmap *bitmap)
    977 {
    978     if(!bitmap)
     969 * \brief Free the memory associated with a dither.
     970 *
     971 * Free the memory allocated by cucul_create_dither().
     972 *
     973 * \param dither Dither object.
     974 */
     975void cucul_free_dither(struct cucul_dither *d)
     976{
     977    if(!d)
    979978        return;
    980979
    981     free(bitmap);
     980    free(d);
    982981}
    983982
     
    10751074}
    10761075
    1077 static void get_rgba_default(struct cucul_bitmap const *bitmap, uint8_t *pixels,
     1076static void get_rgba_default(struct cucul_dither const *d, uint8_t *pixels,
    10781077                             int x, int y, unsigned int *rgba)
    10791078{
    10801079    uint32_t bits;
    10811080
    1082     pixels += (bitmap->bpp / 8) * x + bitmap->pitch * y;
    1083 
    1084     switch(bitmap->bpp / 8)
     1081    pixels += (d->bpp / 8) * x + d->pitch * y;
     1082
     1083    switch(d->bpp / 8)
    10851084    {
    10861085        case 4:
     
    11141113    }
    11151114
    1116     if(bitmap->has_palette)
    1117     {
    1118         rgba[0] += bitmap->gammatab[bitmap->red[bits]];
    1119         rgba[1] += bitmap->gammatab[bitmap->green[bits]];
    1120         rgba[2] += bitmap->gammatab[bitmap->blue[bits]];
    1121         rgba[3] += bitmap->alpha[bits];
     1115    if(d->has_palette)
     1116    {
     1117        rgba[0] += d->gammatab[d->red[bits]];
     1118        rgba[1] += d->gammatab[d->green[bits]];
     1119        rgba[2] += d->gammatab[d->blue[bits]];
     1120        rgba[3] += d->alpha[bits];
    11221121    }
    11231122    else
    11241123    {
    1125         rgba[0] += bitmap->gammatab[((bits & bitmap->rmask) >> bitmap->rright) << bitmap->rleft];
    1126         rgba[1] += bitmap->gammatab[((bits & bitmap->gmask) >> bitmap->gright) << bitmap->gleft];
    1127         rgba[2] += bitmap->gammatab[((bits & bitmap->bmask) >> bitmap->bright) << bitmap->bleft];
    1128         rgba[3] += ((bits & bitmap->amask) >> bitmap->aright) << bitmap->aleft;
     1124        rgba[0] += d->gammatab[((bits & d->rmask) >> d->rright) << d->rleft];
     1125        rgba[1] += d->gammatab[((bits & d->gmask) >> d->gright) << d->gleft];
     1126        rgba[2] += d->gammatab[((bits & d->bmask) >> d->bright) << d->bleft];
     1127        rgba[3] += ((bits & d->amask) >> d->aright) << d->aleft;
    11291128    }
    11301129}
     
    12811280
    12821281#if !defined(_DOXYGEN_SKIP_ME)
    1283 int _cucul_init_bitmap(void)
     1282int _cucul_init_dither(void)
    12841283{
    12851284    unsigned int v, s, h;
     
    13391338}
    13401339
    1341 int _cucul_end_bitmap(void)
     1340int _cucul_end_dither(void)
    13421341{
    13431342    return 0;
  • libcaca/trunk/cucul/cucul.c

    r733 r734  
    6666        _cucul_set_size(qq, 80, 32);
    6767
    68     if(_cucul_init_bitmap())
     68    if(_cucul_init_dither())
    6969    {
    7070        free(qq);
     
    214214void cucul_free(cucul_t *qq)
    215215{
    216     _cucul_end_bitmap();
     216    _cucul_end_dither();
    217217
    218218    free(qq->empty_line);
  • libcaca/trunk/cucul/cucul.h

    r733 r734  
    147147/*  @} */
    148148
    149 /** \defgroup bitmap Bitmap handling
    150  *
    151  *  These functions provide high level routines for bitmap allocation and
     149/** \defgroup dither Bitmap dithering
     150 *
     151 *  These functions provide high level routines for dither allocation and
    152152 *  rendering.
    153153 *
    154154 *  @{ */
    155 struct cucul_bitmap;
    156 struct cucul_bitmap *cucul_create_bitmap(unsigned int, unsigned int,
     155struct cucul_dither;
     156struct cucul_dither *cucul_create_dither(unsigned int, unsigned int,
    157157                                         unsigned int, unsigned int,
    158158                                         unsigned int, unsigned int,
    159159                                         unsigned int, unsigned int);
    160 void cucul_set_bitmap_palette(struct cucul_bitmap *,
     160void cucul_set_dither_palette(struct cucul_dither *,
    161161                              unsigned int r[], unsigned int g[],
    162162                              unsigned int b[], unsigned int a[]);
    163 void cucul_set_bitmap_brightness(struct cucul_bitmap *, float);
    164 void cucul_set_bitmap_gamma(struct cucul_bitmap *, float);
    165 void cucul_set_bitmap_contrast(struct cucul_bitmap *, float);
    166 void cucul_set_bitmap_invert(struct cucul_bitmap *, int);
    167 void cucul_set_bitmap_antialias(struct cucul_bitmap *, char const *);
    168 char const * const * cucul_get_bitmap_antialias_list(struct cucul_bitmap const *);
    169 void cucul_set_bitmap_color(struct cucul_bitmap *, char const *);
    170 char const * const * cucul_get_bitmap_color_list(struct cucul_bitmap const *);
    171 void cucul_set_bitmap_charset(struct cucul_bitmap *, char const *);
    172 char const * const * cucul_get_bitmap_charset_list(struct cucul_bitmap
    173                                                    const *);
    174 void cucul_set_bitmap_dithering(struct cucul_bitmap *, char const *);
    175 char const * const * cucul_get_bitmap_dithering_list(struct cucul_bitmap
    176                                                      const *);
    177 void cucul_draw_bitmap(cucul_t *, int, int, int, int,
    178                        struct cucul_bitmap const *, void *);
    179 void cucul_free_bitmap(struct cucul_bitmap *);
     163void cucul_set_dither_brightness(struct cucul_dither *, float);
     164void cucul_set_dither_gamma(struct cucul_dither *, float);
     165void cucul_set_dither_contrast(struct cucul_dither *, float);
     166void cucul_set_dither_invert(struct cucul_dither *, int);
     167void cucul_set_dither_antialias(struct cucul_dither *, char const *);
     168char const * const * cucul_get_dither_antialias_list(struct cucul_dither const *);
     169void cucul_set_dither_color(struct cucul_dither *, char const *);
     170char const * const * cucul_get_dither_color_list(struct cucul_dither const *);
     171void cucul_set_dither_charset(struct cucul_dither *, char const *);
     172char const * const * cucul_get_dither_charset_list(struct cucul_dither const *);
     173void cucul_set_dither_mode(struct cucul_dither *, char const *);
     174char const * const * cucul_get_dither_mode_list(struct cucul_dither const *);
     175void cucul_dither_bitmap(cucul_t *, int, int, int, int,
     176                         struct cucul_dither const *, void *);
     177void cucul_free_dither(struct cucul_dither *);
    180178/*  @} */
    181179
  • libcaca/trunk/cucul/cucul_internals.h

    r733 r734  
    4848
    4949/* Bitmap functions */
    50 extern int _cucul_init_bitmap(void);
    51 extern int _cucul_end_bitmap(void);
     50extern int _cucul_init_dither(void);
     51extern int _cucul_end_dither(void);
    5252
    5353/* Canvas functions */
  • libcaca/trunk/src/aafire.c

    r710 r734  
    4343static caca_t *kk;
    4444static int XSIZ, YSIZ;
    45 static struct cucul_bitmap *cucul_bitmap;
     45static struct cucul_dither *cucul_dither;
    4646static char *bitmap;
    4747static int pause = 0;
     
    141141
    142142#ifdef LIBCACA
    143   cucul_bitmap = cucul_create_bitmap(8, XSIZ, YSIZ - 2, XSIZ, 0, 0, 0, 0);
    144   cucul_set_bitmap_palette(cucul_bitmap, r, g, b, a);
     143  cucul_dither = cucul_create_dither(8, XSIZ, YSIZ - 2, XSIZ, 0, 0, 0, 0);
     144  cucul_set_dither_palette(cucul_dither, r, g, b, a);
    145145  bitmap = malloc(4 * cucul_get_width(qq) * cucul_get_height(qq) * sizeof(char));
    146146  memset(bitmap, 0, 4 * cucul_get_width(qq) * cucul_get_height(qq));
     
    236236#ifdef LIBCACA
    237237paused:
    238   cucul_draw_bitmap(qq, 0, 0,
    239                     cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
    240                     cucul_bitmap, bitmap);
     238  cucul_dither_bitmap(qq, 0, 0,
     239                      cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
     240                      cucul_dither, bitmap);
    241241  cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
    242242  cucul_putstr(qq, cucul_get_width(qq) - 30, cucul_get_height(qq) - 2,
  • libcaca/trunk/src/cacaball.c

    r710 r734  
    4747    float d[METABALLS], di[METABALLS], dj[METABALLS], dk[METABALLS];
    4848    unsigned int x[METABALLS], y[METABALLS];
    49     struct cucul_bitmap *cucul_bitmap;
     49    struct cucul_dither *cucul_dither;
    5050    float i = 10.0, j = 17.0, k = 11.0;
    5151    int p, frame = 0, pause = 0;
     
    6868    r[255] = g[255] = b[255] = 0xfff;
    6969
    70     /* Create a libcucul bitmap smaller than our pixel buffer, so that we
     70    /* Create a libcucul dither smaller than our pixel buffer, so that we
    7171     * display only the interesting part of it */
    72     cucul_bitmap = cucul_create_bitmap(8, XSIZ - METASIZE, YSIZ - METASIZE,
     72    cucul_dither = cucul_create_dither(8, XSIZ - METASIZE, YSIZ - METASIZE,
    7373                                       XSIZ, 0, 0, 0, 0);
    7474
     
    128128
    129129        /* Set the palette */
    130         cucul_set_bitmap_palette(cucul_bitmap, r, g, b, a);
     130        cucul_set_dither_palette(cucul_dither, r, g, b, a);
    131131
    132132        /* Silly paths for our balls */
     
    154154paused:
    155155        /* Draw our virtual buffer to screen, letting libcucul resize it */
    156         cucul_draw_bitmap(qq, 0, 0,
     156        cucul_dither_bitmap(qq, 0, 0,
    157157                          cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
    158                           cucul_bitmap, pixels + (METASIZE / 2) * (1 + XSIZ));
     158                          cucul_dither, pixels + (METASIZE / 2) * (1 + XSIZ));
    159159        cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
    160160        cucul_putstr(qq, cucul_get_width(qq) - 30, cucul_get_height(qq) - 2,
     
    166166    /* End, bye folks */
    167167end:
    168     cucul_free_bitmap(cucul_bitmap);
     168    cucul_free_dither(cucul_dither);
    169169    caca_detach(kk);
    170170    cucul_free(qq);
  • libcaca/trunk/src/cacamoir.c

    r710 r734  
    4040    cucul_t *qq; caca_t *kk;
    4141    unsigned int red[256], green[256], blue[256], alpha[256];
    42     struct cucul_bitmap *bitmap;
     42    struct cucul_dither *dither;
    4343    int i, x, y, frame = 0, pause = 0;
    4444
     
    6363        draw_disc(i, (i / DISCTHICKNESS) % 2);
    6464
    65     /* Create a libcucul bitmap */
    66     bitmap = cucul_create_bitmap(8, XSIZ, YSIZ, XSIZ, 0, 0, 0, 0);
     65    /* Create a libcucul dither */
     66    dither = cucul_create_dither(8, XSIZ, YSIZ, XSIZ, 0, 0, 0, 0);
    6767
    6868    /* Main loop */
     
    9393        blue[1] = 0.5 * (1 + cos(0.05 * frame + 5.0)) * 0xfff;
    9494
    95         cucul_set_bitmap_palette(bitmap, red, green, blue, alpha);
     95        cucul_set_dither_palette(dither, red, green, blue, alpha);
    9696
    9797        /* Draw circles */
     
    107107
    108108paused:
    109         cucul_draw_bitmap(qq, 0, 0,
    110                           cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
    111                           bitmap, screen);
     109        cucul_dither_bitmap(qq, 0, 0,
     110                            cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
     111                            dither, screen);
    112112        cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
    113113        cucul_putstr(qq, cucul_get_width(qq) - 30, cucul_get_height(qq) - 2,
     
    117117
    118118end:
    119     cucul_free_bitmap(bitmap);
     119    cucul_free_dither(dither);
    120120    caca_detach(kk);
    121121    cucul_free(qq);
  • libcaca/trunk/src/cacaplas.c

    r716 r734  
    4444    unsigned int red[256], green[256], blue[256], alpha[256];
    4545    double r[3], R[6];
    46     struct cucul_bitmap *bitmap;
     46    struct cucul_dither *dither;
    4747    int i, x, y, frame = 0, pause = 0;
    4848
     
    7979    }
    8080
    81     /* Create a libcucul bitmap */
    82     bitmap = cucul_create_bitmap(8, XSIZ, YSIZ, XSIZ, 0, 0, 0, 0);
     81    /* Create a libcucul dither */
     82    dither = cucul_create_dither(8, XSIZ, YSIZ, XSIZ, 0, 0, 0, 0);
    8383
    8484    /* Main loop */
     
    108108
    109109        /* Set the palette */
    110         cucul_set_bitmap_palette(bitmap, red, green, blue, alpha);
     110        cucul_set_dither_palette(dither, red, green, blue, alpha);
    111111
    112112        do_plasma(screen,
     
    120120
    121121paused:
    122         cucul_draw_bitmap(qq, 0, 0,
    123                           cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
    124                           bitmap, screen);
     122        cucul_dither_bitmap(qq, 0, 0,
     123                            cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
     124                            dither, screen);
    125125
    126126        cucul_blit(qq2, 0, 0, qq, NULL);
     
    137137
    138138end:
    139     cucul_free_bitmap(bitmap);
     139    cucul_free_dither(dither);
    140140    caca_detach(kk);
    141141    cucul_free(qq);
  • libcaca/trunk/src/cacaview.c

    r710 r734  
    6868#endif
    6969char *pixels = NULL;
    70 struct cucul_bitmap *bitmap = NULL;
     70struct cucul_dither *dither = NULL;
    7171unsigned int w, h, depth, bpp, rmask, gmask, bmask, amask;
    7272#if !defined(HAVE_IMLIB2_H)
     
    383383                          y + height * (1.0 + yfactor) / 2);
    384384
    385             cucul_draw_bitmap(qq, ww * (1.0 - xfactor) * xdelta,
     385            cucul_dither_bitmap(qq, ww * (1.0 - xfactor) * xdelta,
    386386                              y + height * (1.0 - yfactor) * ydelta,
    387387                              ww * (xdelta + (1.0 - xdelta) * xfactor),
    388388                              y + height * (ydelta + (1.0 - ydelta) * yfactor),
    389                               bitmap, pixels);
     389                              dither, pixels);
    390390        }
    391391
     
    507507    if(g < -GAMMA_MAX) g = -GAMMA_MAX;
    508508
    509     cucul_set_bitmap_gamma(bitmap, (g < 0) ? 1.0 / gammatab[-g] : gammatab[g]);
     509    cucul_set_dither_gamma(dither, (g < 0) ? 1.0 / gammatab[-g] : gammatab[g]);
    510510}
    511511
     
    522522    pixels = NULL;
    523523#endif
    524     if(bitmap)
    525         cucul_free_bitmap(bitmap);
    526     bitmap = NULL;
     524    if(dither)
     525        cucul_free_dither(dither);
     526    dither = NULL;
    527527}
    528528
     
    547547    depth = 4;
    548548
    549     /* Create the libcucul bitmap */
    550     bitmap = cucul_create_bitmap(bpp, w, h, depth * w,
     549    /* Create the libcucul dither */
     550    dither = cucul_create_dither(bpp, w, h, depth * w,
    551551                                 rmask, gmask, bmask, amask);
    552     if(!bitmap)
     552    if(!dither)
    553553    {
    554554        imlib_free_image();
     
    653653    memset(pixels, 0, w * h * depth);
    654654
    655     /* Read the bitmap data */
     655    /* Read the dither data */
    656656    for(i = h; i--; )
    657657    {
     
    715715    fclose(fp);
    716716
    717     /* Create the libcucul bitmap */
    718     bitmap = cucul_create_bitmap(bpp, w, h, depth * w,
     717    /* Create the libcucul dither */
     718    dither = cucul_create_dither(bpp, w, h, depth * w,
    719719                                 rmask, gmask, bmask, amask);
    720     if(!bitmap)
     720    if(!dither)
    721721    {
    722722        free(pixels);
     
    726726
    727727    if(bpp == 8)
    728         cucul_set_bitmap_palette(bitmap, red, green, blue, alpha);
     728        cucul_set_dither_palette(dither, red, green, blue, alpha);
    729729#endif
    730730}
  • libcaca/trunk/test/demo.c

    r711 r734  
    484484static void demo_render(void)
    485485{
    486     struct cucul_bitmap *bitmap;
     486    struct cucul_dither *dither;
    487487    //short buffer[256*256];
    488488    //short *dest = buffer;
     
    501501        *dest++ = (x << 16) | (y << 8) | (z);
    502502    }
    503     cucul_set_bitmap_invert(bitmap, 1);
    504     //bitmap = cucul_create_bitmap(16, 256, 256, 2 * 256, 0xf800, 0x07e0, 0x001f, 0x0000);
    505     bitmap = cucul_create_bitmap(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
    506     cucul_draw_bitmap(qq, 0, 0, cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
    507                      bitmap, buffer);
    508     cucul_free_bitmap(bitmap);
     503    cucul_set_dither_invert(dither, 1);
     504    //dither = cucul_create_dither(16, 256, 256, 2 * 256, 0xf800, 0x07e0, 0x001f, 0x0000);
     505    dither = cucul_create_dither(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
     506    cucul_dither_bitmap(qq, 0, 0, cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
     507                     dither, buffer);
     508    cucul_free_dither(dither);
    509509}
    510510#endif
     
    514514static void demo_render(void)
    515515{
    516     struct cucul_bitmap *bitmap;
     516    struct cucul_dither *dither;
    517517    int buffer[256*256];
    518518    int *dest;
     
    547547        draw_circle(buffer, xo, yo, z, 0x000000ff, 200);
    548548
    549     bitmap = cucul_create_bitmap(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
    550  cucul_set_bitmap_invert(bitmap, 1);
    551     cucul_draw_bitmap(qq, 0, 0, cucul_get_width(qq) - 1, cucul_get_height(qq) - 1, bitmap, (char *)buffer);
    552     cucul_free_bitmap(bitmap);
     549    dither = cucul_create_dither(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
     550 cucul_set_dither_invert(dither, 1);
     551    cucul_dither_bitmap(qq, 0, 0, cucul_get_width(qq) - 1, cucul_get_height(qq) - 1, dither, (char *)buffer);
     552    cucul_free_dither(dither);
    553553}
    554554
  • libcaca/trunk/test/export.c

    r706 r734  
    3636{
    3737    cucul_t *qq;
    38     struct cucul_bitmap *bitmap;
     38    struct cucul_dither *dither;
    3939    struct cucul_export *buffer;
    4040    int x, y;
     
    7373    }
    7474
    75     bitmap = cucul_create_bitmap(32, 256, 256, 4 * 256,
     75    dither = cucul_create_dither(32, 256, 256, 4 * 256,
    7676                                 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
    77     cucul_draw_bitmap(qq, 0, 0,
    78                       cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
    79                       bitmap, pixels);
    80     cucul_free_bitmap(bitmap);
     77    cucul_dither_bitmap(qq, 0, 0,
     78                        cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
     79                        dither, pixels);
     80    cucul_free_dither(dither);
    8181
    8282    cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
  • libcaca/trunk/test/gamma.c

    r710 r734  
    3737    cucul_t *qq, *gg, *mask;
    3838    caca_t *kk;
    39     struct cucul_bitmap *left, *right;
     39    struct cucul_dither *left, *right;
    4040    float gam = 1.0;
    4141    int x;
     
    5555    }
    5656
    57     left = cucul_create_bitmap(32, 256, 4, 4 * 256,
     57    left = cucul_create_dither(32, 256, 4, 4 * 256,
    5858                               0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
    59     right = cucul_create_bitmap(32, 256, 4, 4 * 256,
     59    right = cucul_create_dither(32, 256, 4, 4 * 256,
    6060                                0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
    6161    caca_set_delay(kk, 20000);
     
    8181        cucul_set_size(mask, cucul_get_width(qq), cucul_get_height(qq));
    8282
    83         /* Draw the regular bitmap on the main canvas */
    84         cucul_draw_bitmap(qq, 0, 0,
    85                           cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
    86                           left, buffer);
     83        /* Draw the regular dither on the main canvas */
     84        cucul_dither_bitmap(qq, 0, 0,
     85                            cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
     86                            left, buffer);
    8787
    88         /* Draw the gamma-modified bitmap on the spare canvas */
    89         cucul_set_bitmap_gamma(right, gam);
    90         cucul_draw_bitmap(gg, 0, 0,
    91                           cucul_get_width(gg) - 1, cucul_get_height(gg) - 1,
    92                           right, buffer);
     88        /* Draw the gamma-modified dither on the spare canvas */
     89        cucul_set_dither_gamma(right, gam);
     90        cucul_dither_bitmap(gg, 0, 0,
     91                            cucul_get_width(gg) - 1, cucul_get_height(gg) - 1,
     92                            right, buffer);
    9393
    9494        /* Draw something on the mask */
     
    112112    }
    113113
    114     cucul_free_bitmap(left);
    115     cucul_free_bitmap(right);
     114    cucul_free_dither(left);
     115    cucul_free_dither(right);
    116116
    117117    caca_detach(kk);
  • libcaca/trunk/test/hsv.c

    r710 r734  
    3333    caca_t *kk;
    3434
    35     struct cucul_bitmap *bitmap;
     35    struct cucul_dither *dither;
    3636    int x, y;
    3737
     
    4545    }
    4646
    47     bitmap = cucul_create_bitmap(32, 256, 256, 4 * 256,
     47    dither = cucul_create_dither(32, 256, 256, 4 * 256,
    4848                                 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
    49     cucul_draw_bitmap(qq, 0, 0,
    50                       cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
    51                       bitmap, buffer);
    52     cucul_free_bitmap(bitmap);
     49    cucul_dither_bitmap(qq, 0, 0,
     50                        cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
     51                        dither, buffer);
     52    cucul_free_dither(dither);
    5353
    5454    caca_display(kk);
Note: See TracChangeset for help on using the changeset viewer.