File: loaders.c

package info (click to toggle)
simage 1.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,912 kB
  • ctags: 1,572
  • sloc: ansic: 14,231; sh: 12,587; cpp: 930; perl: 854; makefile: 617; lisp: 25
file content (43 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <stdlib.h>
#include <simage.h>

int
main(int argc, char ** argv)
{
  int i;

  if (argc < 2) {
    (void)fprintf(stderr, "\n\tUsage: %s IMGFILE [IMGFILES]\n\n", argv[0]);
    exit(1);
  }

  for (i=1; i < argc; i++) {
    const char * filename = argv[i];
    if (!simage_check_supported(filename)) {
      (void)fprintf(stdout, "``%s'' is not in a supported format\n", filename);
    }
    else {
      int w, h, comp;
      unsigned char * buffer = simage_read_image(filename, &w, &h, &comp);

      (void)fprintf(stdout, "``%s'':\n", filename);

      if (!buffer) {
	(void)fprintf(stdout, "\t** couldn't load file: \"%s\"\n",
		      simage_get_last_error());
      }
      else {
	(void)fprintf(stdout, "\twidth: %d, height: %d, components: %d\n",
		      w, h, comp);
  	simage_free_image(buffer);
      }
    }
    (void)fprintf(stdout, "\n");
  }

  /* FIXME: should write testcode for the plugin API functions
     aswell. 20001018 mortene. */

  return 0;
}