source: libpipi/trunk/examples/floodfill.c @ 2694

Last change on this file since 2694 was 2678, checked in by Jean-Yves Lamoureux, 15 years ago
  • Handle alpha layer in floodfill (but don't make it conditionnal to the algorithm)
File size: 815 bytes
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    int ret = 0;
15    if(argc < 4)
16    {
17        fprintf(stderr, "%s: too few arguments\n", argv[0]);
18        fprintf(stderr, "Usage: %s <src> <x> <y> <dest>\n", argv[0]);
19        return EXIT_FAILURE;
20    }
21
22    srcname = argv[1];
23    dstname = argv[4];
24
25    img = pipi_load(srcname);
26
27    if(!img) {
28        fprintf(stderr, "Can't open %s for reading\n", srcname);
29    }
30
31    newimg = pipi_copy(img);
32    pipi_free(img);
33    ret = pipi_flood_fill(newimg, atoi(argv[2]), atoi(argv[3]), 1, 0, 0, 1);
34
35    if(!ret) pipi_save(newimg, dstname);
36
37
38    pipi_free(newimg);
39
40    return ret;
41}
42
Note: See TracBrowser for help on using the repository browser.