Ignore:
Timestamp:
Sep 28, 2008, 7:07:57 AM (12 years ago)
Author:
Sam Hocevar
Message:

Allow to use all available image loaders instead of just the first one.

File:
1 edited

Legend:

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

    r2767 r2837  
    2929pipi_image_t *pipi_load(char const *name)
    3030{
     31    pipi_image_t *ret = NULL;
     32
    3133    if(!strncmp(name, "random:", 7) ||
    3234       !strncmp(name, "ediff:", 6) ||
    3335       !strncmp(name, "halftone:", 6) ||
    3436       !strncmp(name, "bayer:", 6))
    35         return pipi_load_stock(name);
     37        ret = pipi_load_stock(name);
    3638
    3739#if USE_IMLIB2
    38     return pipi_load_imlib2(name);
    39 #elif USE_OPENCV
    40     return pipi_load_opencv(name);
    41 #elif USE_SDL
    42     return pipi_load_sdl(name);
    43 #else
    44 #   error "No imaging library"
     40    if(!ret)
     41        ret = pipi_load_imlib2(name);
    4542#endif
     43#if USE_OPENCV
     44    if(!ret)
     45        ret = pipi_load_opencv(name);
     46#endif
     47#if USE_SDL
     48    if(!ret)
     49        ret = pipi_load_sdl(name);
     50#endif
     51
     52    return ret;
    4653}
    4754
     
    5562
    5663    if(img->codec_priv)
    57 #if USE_IMLIB2
    58         pipi_free_imlib2(img);
    59 #elif USE_OPENCV
    60         pipi_free_opencv(img);
    61 #elif USE_SDL
    62         pipi_free_sdl(img);
    63 #endif
     64        img->codec_free(img);
    6465
    6566    free(img);
    6667}
    6768
    68 void pipi_save(pipi_image_t *img, const char *name)
     69int pipi_save(pipi_image_t *img, const char *name)
    6970{
     71    int ret = -1;
     72
    7073#if USE_IMLIB2
    71     return pipi_save_imlib2(img, name);
    72 #elif USE_OPENCV
    73     return pipi_save_opencv(img, name);
    74 #elif USE_SDL
    75     return pipi_save_sdl(img, name);
     74    if(ret < 0)
     75        ret = pipi_save_imlib2(img, name);
    7676#endif
     77#if USE_OPENCV
     78    if(ret < 0)
     79        ret = pipi_save_opencv(img, name);
     80#endif
     81#if USE_SDL
     82    if(ret < 0)
     83        ret = pipi_save_sdl(img, name);
     84#endif
     85
     86    return ret;
    7787}
    7888
Note: See TracChangeset for help on using the changeset viewer.