source: libpipi/trunk/examples/dither.c @ 2655

Revision 2655, 1.1 KB checked in by sam, 5 years ago (diff)
  • pixels.c: support more conversion combinations.
Line 
1#include "config.h"
2#include "common.h"
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7
8#include <pipi.h>
9
10int main(int argc, char *argv[])
11{
12    char *srcname = NULL, *dstname = NULL;
13    pipi_image_t *img, *newimg;
14
15    if(argc < 3)
16    {
17        fprintf(stderr, "%s: too few arguments\n", argv[0]);
18        fprintf(stderr, "Usage: %s <src> <method> <dest>\n", argv[0]);
19        fprintf(stderr, "Where <method> is one of:\n");
20        fprintf(stderr, "  1   Floyd-Steinberg (serpentine)\n");
21        fprintf(stderr, "  2   Ostromoukhov (serpentine)\n");
22        fprintf(stderr, "  3   Direct binary search\n");
23        return EXIT_FAILURE;
24    }
25
26    srcname = argv[1];
27    dstname = argv[3];
28
29    img = pipi_load(srcname);
30
31    switch(atoi(argv[2]))
32    {
33        case 3:
34            newimg = pipi_dbs(img); break;
35        case 2:
36            newimg = pipi_ostromoukhov(img); break;
37        case 1:
38        default:
39            newimg = pipi_floydsteinberg(img); break;
40    }
41
42    pipi_free(img);
43
44    pipi_save(newimg, dstname);
45    pipi_free(newimg);
46
47    return 0;
48}
49
Note: See TracBrowser for help on using the repository browser.