Changeset 2772 for libpipi


Ignore:
Timestamp:
Aug 26, 2008, 1:39:15 AM (12 years ago)
Author:
Sam Hocevar
Message:
  • pipi.h: add the PIPI_PIXELS_MASK_C pixel format for canvas boundaries.
  • pipi.h: rename RGBA32 and BGR24 into RGBA_C and BGR_C.
Location:
libpipi/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/codec/imlib.c

    r2756 r2772  
    4040    img = pipi_new(imlib_image_get_width(), imlib_image_get_height());
    4141
    42     img->p[PIPI_PIXELS_RGBA32].pixels = imlib_image_get_data();
    43     img->p[PIPI_PIXELS_RGBA32].w = img->w;
    44     img->p[PIPI_PIXELS_RGBA32].h = img->h;
    45     img->p[PIPI_PIXELS_RGBA32].pitch = 4 * img->w;
    46     img->p[PIPI_PIXELS_RGBA32].bpp = 32;
    47     img->p[PIPI_PIXELS_RGBA32].bytes = 4 * img->w * img->h;
    48     img->last_modified = PIPI_PIXELS_RGBA32;
     42    img->p[PIPI_PIXELS_RGBA_C].pixels = imlib_image_get_data();
     43    img->p[PIPI_PIXELS_RGBA_C].w = img->w;
     44    img->p[PIPI_PIXELS_RGBA_C].h = img->h;
     45    img->p[PIPI_PIXELS_RGBA_C].pitch = 4 * img->w;
     46    img->p[PIPI_PIXELS_RGBA_C].bpp = 32;
     47    img->p[PIPI_PIXELS_RGBA_C].bytes = 4 * img->w * img->h;
     48    img->last_modified = PIPI_PIXELS_RGBA_C;
    4949
    5050    img->codec_priv = (void *)priv;
    51     img->codec_format = PIPI_PIXELS_RGBA32;
     51    img->codec_format = PIPI_PIXELS_RGBA_C;
    5252
    5353    img->wrap = 0;
     
    7474
    7575        /* FIXME: check pitch differences here */
    76         if(img->last_modified == PIPI_PIXELS_RGBA32)
     76        if(img->last_modified == PIPI_PIXELS_RGBA_C)
    7777        {
    78             memcpy(data, img->p[PIPI_PIXELS_RGBA32].pixels,
     78            memcpy(data, img->p[PIPI_PIXELS_RGBA_C].pixels,
    7979                   4 * img->w * img->h);
    80             free(img->p[PIPI_PIXELS_RGBA32].pixels);
     80            free(img->p[PIPI_PIXELS_RGBA_C].pixels);
    8181        }
    8282
    83         img->p[PIPI_PIXELS_RGBA32].pixels = data;
    84         img->p[PIPI_PIXELS_RGBA32].w = imlib_image_get_width();
    85         img->p[PIPI_PIXELS_RGBA32].h = imlib_image_get_height();
    86         img->p[PIPI_PIXELS_RGBA32].pitch = 4 * imlib_image_get_width();
    87         img->p[PIPI_PIXELS_RGBA32].bpp = 32;
    88         img->p[PIPI_PIXELS_RGBA32].bytes = 4 * img->w * img->h;
     83        img->p[PIPI_PIXELS_RGBA_C].pixels = data;
     84        img->p[PIPI_PIXELS_RGBA_C].w = imlib_image_get_width();
     85        img->p[PIPI_PIXELS_RGBA_C].h = imlib_image_get_height();
     86        img->p[PIPI_PIXELS_RGBA_C].pitch = 4 * imlib_image_get_width();
     87        img->p[PIPI_PIXELS_RGBA_C].bpp = 32;
     88        img->p[PIPI_PIXELS_RGBA_C].bytes = 4 * img->w * img->h;
    8989
    9090        img->codec_priv = (void *)priv;
    91         img->codec_format = PIPI_PIXELS_RGBA32;
     91        img->codec_format = PIPI_PIXELS_RGBA_C;
    9292
    9393        img->wrap = 0;
  • libpipi/trunk/pipi/codec/opencv.c

    r2756 r2772  
    4242    img = pipi_new(priv->width, priv->height);
    4343
    44     img->p[PIPI_PIXELS_BGR24].pixels = priv->imageData;
    45     img->p[PIPI_PIXELS_BGR24].w = priv->width;
    46     img->p[PIPI_PIXELS_BGR24].h = priv->height;
    47     img->p[PIPI_PIXELS_BGR24].pitch = priv->widthStep;
    48     img->p[PIPI_PIXELS_BGR24].bpp = 24;
    49     img->p[PIPI_PIXELS_BGR24].bytes = 3 * img->w * img->h;
    50     img->last_modified = PIPI_PIXELS_BGR24;
     44    img->p[PIPI_PIXELS_BGR_C].pixels = priv->imageData;
     45    img->p[PIPI_PIXELS_BGR_C].w = priv->width;
     46    img->p[PIPI_PIXELS_BGR_C].h = priv->height;
     47    img->p[PIPI_PIXELS_BGR_C].pitch = priv->widthStep;
     48    img->p[PIPI_PIXELS_BGR_C].bpp = 24;
     49    img->p[PIPI_PIXELS_BGR_C].bytes = 3 * img->w * img->h;
     50    img->last_modified = PIPI_PIXELS_BGR_C;
    5151
    5252    img->codec_priv = (void *)priv;
    53     img->codec_format = PIPI_PIXELS_BGR24;
     53    img->codec_format = PIPI_PIXELS_BGR_C;
    5454
    5555    img->wrap = 0;
     
    7474
    7575        /* FIXME: check pitch differences here */
    76         if(img->last_modified == PIPI_PIXELS_BGR24)
     76        if(img->last_modified == PIPI_PIXELS_BGR_C)
    7777        {
    78             memcpy(priv->imageData, img->p[PIPI_PIXELS_BGR24].pixels,
     78            memcpy(priv->imageData, img->p[PIPI_PIXELS_BGR_C].pixels,
    7979                   3 * img->w * img->h);
    80             free(img->p[PIPI_PIXELS_BGR24].pixels);
     80            free(img->p[PIPI_PIXELS_BGR_C].pixels);
    8181        }
    8282
    83         img->p[PIPI_PIXELS_BGR24].pixels = priv->imageData;
    84         img->p[PIPI_PIXELS_BGR24].w = priv->width;
    85         img->p[PIPI_PIXELS_BGR24].h = priv->height;
    86         img->p[PIPI_PIXELS_BGR24].pitch = priv->widthStep;
    87         img->p[PIPI_PIXELS_BGR24].bpp = 24;
    88         img->p[PIPI_PIXELS_BGR24].bytes = 3 * img->w * img->h;
     83        img->p[PIPI_PIXELS_BGR_C].pixels = priv->imageData;
     84        img->p[PIPI_PIXELS_BGR_C].w = priv->width;
     85        img->p[PIPI_PIXELS_BGR_C].h = priv->height;
     86        img->p[PIPI_PIXELS_BGR_C].pitch = priv->widthStep;
     87        img->p[PIPI_PIXELS_BGR_C].bpp = 24;
     88        img->p[PIPI_PIXELS_BGR_C].bytes = 3 * img->w * img->h;
    8989
    9090        img->codec_priv = (void *)priv;
    91         img->codec_format = PIPI_PIXELS_BGR24;
     91        img->codec_format = PIPI_PIXELS_BGR_C;
    9292
    9393        img->wrap = 0;
  • libpipi/trunk/pipi/codec/sdl.c

    r2756 r2772  
    4949    img = pipi_new(priv->w, priv->h);
    5050
    51     img->p[PIPI_PIXELS_RGBA32].pixels = priv->pixels;
    52     img->p[PIPI_PIXELS_RGBA32].w = priv->w;
    53     img->p[PIPI_PIXELS_RGBA32].h = priv->h;
    54     img->p[PIPI_PIXELS_RGBA32].pitch = priv->pitch;
    55     img->p[PIPI_PIXELS_RGBA32].bpp = 32;
    56     img->p[PIPI_PIXELS_RGBA32].bytes = 4 * img->w * img->h;
    57     img->last_modified = PIPI_PIXELS_RGBA32;
     51    img->p[PIPI_PIXELS_RGBA_C].pixels = priv->pixels;
     52    img->p[PIPI_PIXELS_RGBA_C].w = priv->w;
     53    img->p[PIPI_PIXELS_RGBA_C].h = priv->h;
     54    img->p[PIPI_PIXELS_RGBA_C].pitch = priv->pitch;
     55    img->p[PIPI_PIXELS_RGBA_C].bpp = 32;
     56    img->p[PIPI_PIXELS_RGBA_C].bytes = 4 * img->w * img->h;
     57    img->last_modified = PIPI_PIXELS_RGBA_C;
    5858
    5959    img->codec_priv = (void *)priv;
    60     img->codec_format = PIPI_PIXELS_RGBA32;
     60    img->codec_format = PIPI_PIXELS_RGBA_C;
    6161
    6262    img->wrap = 0;
     
    7878
    7979        /* FIXME: check pitch differences here */
    80         if(img->last_modified == PIPI_PIXELS_RGBA32)
     80        if(img->last_modified == PIPI_PIXELS_RGBA_C)
    8181        {
    82             memcpy(priv->pixels, img->p[PIPI_PIXELS_RGBA32].pixels,
     82            memcpy(priv->pixels, img->p[PIPI_PIXELS_RGBA_C].pixels,
    8383                   priv->pitch * priv->h);
    84             free(img->p[PIPI_PIXELS_RGBA32].pixels);
     84            free(img->p[PIPI_PIXELS_RGBA_C].pixels);
    8585        }
    8686
    87         img->p[PIPI_PIXELS_RGBA32].pixels = priv->pixels;
    88         img->p[PIPI_PIXELS_RGBA32].w = priv->w;
    89         img->p[PIPI_PIXELS_RGBA32].h = priv->h;
    90         img->p[PIPI_PIXELS_RGBA32].pitch = priv->pitch;
    91         img->p[PIPI_PIXELS_RGBA32].bpp = 32;
    92         img->p[PIPI_PIXELS_RGBA32].bytes = 4 * img->w * img->h;
     87        img->p[PIPI_PIXELS_RGBA_C].pixels = priv->pixels;
     88        img->p[PIPI_PIXELS_RGBA_C].w = priv->w;
     89        img->p[PIPI_PIXELS_RGBA_C].h = priv->h;
     90        img->p[PIPI_PIXELS_RGBA_C].pitch = priv->pitch;
     91        img->p[PIPI_PIXELS_RGBA_C].bpp = 32;
     92        img->p[PIPI_PIXELS_RGBA_C].bytes = 4 * img->w * img->h;
    9393
    9494        img->codec_priv = (void *)priv;
    95         img->codec_format = PIPI_PIXELS_RGBA32;
     95        img->codec_format = PIPI_PIXELS_RGBA_C;
    9696
    9797        img->wrap = 0;
  • libpipi/trunk/pipi/paint/floodfill.c

    r2717 r2772  
    7979
    8080
    81     if(src->last_modified == PIPI_PIXELS_RGBA32) {
     81    if(src->last_modified == PIPI_PIXELS_RGBA_C) {
    8282        uint32_t  *dstdata;
    8383        unsigned char nr, ng, nb, na;
    8484
    8585        /* Get ARGB32 pointer */
    86         dstp = pipi_getpixels(dst, PIPI_PIXELS_RGBA32);
     86        dstp = pipi_getpixels(dst, PIPI_PIXELS_RGBA_C);
    8787        dstdata = (uint32_t *)dstp->pixels;
    8888
  • libpipi/trunk/pipi/pipi.h

    r2767 r2772  
    4444    PIPI_PIXELS_UNINITIALISED = -1,
    4545
    46     PIPI_PIXELS_RGBA32 = 0,
    47     PIPI_PIXELS_BGR24 = 1,
     46    PIPI_PIXELS_RGBA_C = 0,
     47    PIPI_PIXELS_BGR_C = 1,
    4848    PIPI_PIXELS_RGBA_F = 2,
    4949    PIPI_PIXELS_Y_F = 3,
    5050
    51     PIPI_PIXELS_MAX = 4
     51    PIPI_PIXELS_MASK_C = 4,
     52
     53    PIPI_PIXELS_MAX = 5
    5254}
    5355pipi_format_t;
  • libpipi/trunk/pipi/pixels.c

    r2768 r2772  
    5050
    5151    /* Preliminary conversions */
    52     if(img->last_modified == PIPI_PIXELS_RGBA32
     52    if(img->last_modified == PIPI_PIXELS_RGBA_C
    5353                  && type == PIPI_PIXELS_Y_F)
    5454        pipi_getpixels(img, PIPI_PIXELS_RGBA_F);
    55     else if(img->last_modified == PIPI_PIXELS_BGR24
     55    else if(img->last_modified == PIPI_PIXELS_BGR_C
    5656                       && type == PIPI_PIXELS_Y_F)
    5757        pipi_getpixels(img, PIPI_PIXELS_RGBA_F);
    5858    else if(img->last_modified == PIPI_PIXELS_Y_F
    59                        && type == PIPI_PIXELS_RGBA32)
     59                       && type == PIPI_PIXELS_RGBA_C)
    6060        pipi_getpixels(img, PIPI_PIXELS_RGBA_F);
    6161    else if(img->last_modified == PIPI_PIXELS_Y_F
    62                        && type == PIPI_PIXELS_BGR24)
     62                       && type == PIPI_PIXELS_BGR_C)
    6363        pipi_getpixels(img, PIPI_PIXELS_RGBA_F);
    6464
     
    6868        switch(type)
    6969        {
    70         case PIPI_PIXELS_RGBA32:
     70        case PIPI_PIXELS_RGBA_C:
    7171            bytes = img->w * img->h * 4 * sizeof(uint8_t);
    7272            bpp = 4 * sizeof(uint8_t);
    7373            break;
    74         case PIPI_PIXELS_BGR24:
     74        case PIPI_PIXELS_BGR_C:
    7575            bytes = img->w * img->h * 3 * sizeof(uint8_t);
    7676            bpp = 3 * sizeof(uint8_t);
     
    9696
    9797    /* Convert pixels */
    98     if(img->last_modified == PIPI_PIXELS_RGBA32
     98    if(img->last_modified == PIPI_PIXELS_RGBA_C
    9999                  && type == PIPI_PIXELS_RGBA_F)
    100100    {
    101         uint8_t *src = (uint8_t *)img->p[PIPI_PIXELS_RGBA32].pixels;
     101        uint8_t *src = (uint8_t *)img->p[PIPI_PIXELS_RGBA_C].pixels;
    102102        float *dest = (float *)img->p[type].pixels;
    103103
     
    110110                        = u8tof32(src[4 * (y * img->w + x) + i]);
    111111    }
    112     else if(img->last_modified == PIPI_PIXELS_BGR24
     112    else if(img->last_modified == PIPI_PIXELS_BGR_C
    113113                       && type == PIPI_PIXELS_RGBA_F)
    114114    {
    115         uint8_t *src = (uint8_t *)img->p[PIPI_PIXELS_BGR24].pixels;
     115        uint8_t *src = (uint8_t *)img->p[PIPI_PIXELS_BGR_C].pixels;
    116116        float *dest = (float *)img->p[type].pixels;
    117117
     
    131131    }
    132132    else if(img->last_modified == PIPI_PIXELS_RGBA_F
    133                        && type == PIPI_PIXELS_RGBA32)
     133                       && type == PIPI_PIXELS_RGBA_C)
    134134    {
    135135        float *src = (float *)img->p[PIPI_PIXELS_RGBA_F].pixels;
     
    167167    }
    168168    else if(img->last_modified == PIPI_PIXELS_RGBA_F
    169                        && type == PIPI_PIXELS_BGR24)
     169                       && type == PIPI_PIXELS_BGR_C)
    170170    {
    171171        float *src = (float *)img->p[PIPI_PIXELS_RGBA_F].pixels;
  • libpipi/trunk/test/u8tof32tou8.c

    r2621 r2772  
    3636    img2 = pipi_load("mona.png");
    3737
    38     pix1 = pipi_getpixels(img1, PIPI_PIXELS_RGBA32);
     38    pix1 = pipi_getpixels(img1, PIPI_PIXELS_RGBA_C);
    3939    data1 = (uint32_t *)pix1->pixels;
    4040
    4141    pipi_getpixels(img2, PIPI_PIXELS_RGBA_F);
    42     pix2 = pipi_getpixels(img2, PIPI_PIXELS_RGBA32);
     42    pix2 = pipi_getpixels(img2, PIPI_PIXELS_RGBA_C);
    4343    data2 = (uint32_t *)pix2->pixels;
    4444
Note: See TracChangeset for help on using the changeset viewer.