Ignore:
Timestamp:
Nov 30, 2003, 4:01:55 PM (17 years ago)
Author:
Sam Hocevar
Message:
  • src/bitmap.c: + Fixed an endianness issue in the byte reader. + Decreased precision in RGB and HSV values to avoid overflows. + New dithering method: 2x2 ordered. + New renderer, with background colour awareness.
  • configure.ac: + Check for <endian.h>.
  • examples/demo.c examples/view.c: + Fixed an endianness issue in cacaview. + Adapted code to the additional dithering method.
Location:
libcaca/trunk/examples
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/examples/demo.c

    r235 r238  
    101101            case 'd':
    102102            case 'D':
    103                 dithering = (dithering + 1) % 4;
     103                dithering = (dithering + 1) % 5;
    104104                caca_set_dithering(dithering);
    105105                display_menu();
  • libcaca/trunk/examples/view.c

    r237 r238  
    2929#include <unistd.h>
    3030
     31#ifdef HAVE_ENDIAN_H
     32#   include <endian.h>
     33#endif
     34
    3135#include <Imlib2.h>
    3236
     
    3741struct caca_bitmap *bitmap = NULL;
    3842int x, y, w, h;
     43unsigned int rmask, gmask, bmask;
    3944
    4045int dithering = CACA_DITHERING_ORDERED4;
     
    4954    char **list = NULL;
    5055    int current = 0, items = 0, opts = 1;
     56
     57#ifdef HAVE_ENDIAN_H
     58    if(__BYTE_ORDER == __BIG_ENDIAN)
     59#else
     60    rmask = 0x12345678;
     61    if(*(char *)&rmask == 0x12)
     62#endif
     63    {
     64        rmask = 0x00ff0000; gmask = 0x0000ff00; bmask = 0x000000ff;
     65    }
     66    else
     67    {
     68        rmask = 0x0000ff00; gmask = 0x00ff0000; bmask = 0xff000000;
     69    }
    5170
    5271    /* Initialise libcaca */
     
    102121                break;
    103122            case CACA_EVENT_KEY_PRESS | 'd':
    104                 dithering = (dithering + 1) % 4;
     123                dithering = (dithering + 1) % 5;
    105124                update = 1;
    106125                break;
    107126            case CACA_EVENT_KEY_PRESS | 'D':
    108                 dithering = (dithering - 1) % 4;
     127                dithering = (dithering + 4) % 5;
    109128                update = 1;
    110129                break;
     
    216235            if(yn + y > h) y = h - yn;
    217236            newbitmap = caca_create_bitmap(32, 2 * xn, 2 * yn, 4 * w,
    218                                        0x0000ff00, 0x00ff0000, 0xff000000);
     237                                           rmask, gmask, bmask);
    219238            caca_draw_bitmap(0, 0, ww - 1, wh - 1, newbitmap,
    220239                             pixels + 4 * (x - xn) + 4 * w * (y - yn));
     
    298317
    299318    /* Create the libcaca bitmap */
    300     bitmap = caca_create_bitmap(32, w, h, 4 * w,
    301                                 0x0000ff00, 0x00ff0000, 0xff000000);
     319    bitmap = caca_create_bitmap(32, w, h, 4 * w, rmask, gmask, bmask);
    302320    if(!bitmap)
    303321    {
Note: See TracChangeset for help on using the changeset viewer.