Changeset 2694


Ignore:
Timestamp:
Aug 11, 2008, 2:51:05 AM (15 years ago)
Author:
Sam Hocevar
Message:
  • context.c: implement various dithering commands and Gaussian blur.
  • pipi.c: add "--blur" and "--dither" commandline options.
  • blur.c dither.c: remove these examples, pipi.c works a lot better:

pipi src.png --blur 10 dest.png
pipi src.png --dither dbs dest.png

(and of course combinations are possible)

Location:
libpipi/trunk
Files:
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/.gitignore

    r2693 r2694  
    1212src/pipi
    1313genethumb/genethumb
    14 examples/blur
    15 examples/dither
    1614examples/edd
     15examples/floodfill
    1716examples/img2rubik
    1817examples/sharpen
  • libpipi/trunk/examples/Makefile.am

    r2676 r2694  
    33AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/pipi
    44
    5 bin_PROGRAMS = blur dither edd img2rubik sharpen floodfill
    6 
    7 blur_SOURCES = blur.c
    8 blur_LDADD = ../pipi/libpipi.la
    9 
    10 dither_SOURCES = dither.c
    11 dither_LDADD = ../pipi/libpipi.la
     5bin_PROGRAMS = edd img2rubik sharpen floodfill
    126
    137edd_SOURCES = edd.c
  • libpipi/trunk/pipi/context.c

    r2692 r2694  
    7272        pipi_free(ctx->images[ctx->nimages]);
    7373    }
     74    else if(!strcmp(cmd, "dither"))
     75    {
     76        pipi_image_t *src, *dst;
     77        char const *method;
     78        va_list ap;
     79
     80        if(ctx->nimages <= 0)
     81            return -1;
     82        va_start(ap, cmd);
     83        method = va_arg(ap, char const *);
     84        va_end(ap);
     85        src = ctx->images[ctx->nimages - 1];
     86        dst = NULL;
     87        if(!strcmp(method, "fs"))
     88            dst = pipi_dither_floydsteinberg(src, 0);
     89        else if(!strcmp(method, "sfs"))
     90            dst = pipi_dither_floydsteinberg(src, 1);
     91        else if(!strcmp(method, "ost"))
     92            dst = pipi_dither_ostromoukhov(src, 0);
     93        else if(!strcmp(method, "sost"))
     94            dst = pipi_dither_ostromoukhov(src, 1);
     95        else if(!strcmp(method, "ordered"))
     96            dst = pipi_dither_ordered(src);
     97        else if(!strcmp(method, "random"))
     98            dst = pipi_dither_random(src);
     99        else if(!strcmp(method, "dbs"))
     100            dst = pipi_dither_dbs(src);
     101        if(dst == NULL)
     102            return -1;
     103        pipi_free(src);
     104        ctx->images[ctx->nimages - 1] = dst;
     105    }
     106    else if(!strcmp(cmd, "blur"))
     107    {
     108        pipi_image_t *src, *dst;
     109        char const *arg;
     110        va_list ap;
     111
     112        if(ctx->nimages <= 0)
     113            return -1;
     114        va_start(ap, cmd);
     115        arg = va_arg(ap, char const *);
     116        va_end(ap);
     117        src = ctx->images[ctx->nimages - 1];
     118        dst = pipi_gaussian_blur(src, atoi(arg));
     119        if(dst == NULL)
     120            return -1;
     121        pipi_free(src);
     122        ctx->images[ctx->nimages - 1] = dst;
     123    }
    74124    else if(!strcmp(cmd, "free"))
    75125    {
  • libpipi/trunk/src/pipi.c

    r2693 r2694  
    1616    while(*++argv)
    1717    {
    18         if(!strcmp(argv[0], "--output") || !strcmp(argv[0], "-o"))
     18        if(!strcmp(argv[0], "--dup"))
     19        {
     20            if(pipi_command(ctx, "dup") != 0)
     21                return EXIT_FAILURE;
     22        }
     23        else if(!strcmp(argv[0], "--dither"))
     24        {
     25            if(argv[1] == NULL)
     26                return EXIT_FAILURE;
     27            if(pipi_command(ctx, "dither", argv[1]) != 0)
     28                return EXIT_FAILURE;
     29            argv++;
     30        }
     31        else if(!strcmp(argv[0], "--blur"))
     32        {
     33            if(argv[1] == NULL)
     34                return EXIT_FAILURE;
     35            if(pipi_command(ctx, "blur", argv[1]) != 0)
     36                return EXIT_FAILURE;
     37            argv++;
     38        }
     39        else if(!strcmp(argv[0], "--output") || !strcmp(argv[0], "-o"))
    1940        {
    2041            if(argv[1] == NULL)
Note: See TracChangeset for help on using the changeset viewer.