Changeset 2258 for libpipi/trunk/genethumb/genethumb.c
- Timestamp:
- Mar 11, 2008, 3:56:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/genethumb/genethumb.c
r2247 r2258 2 2 #include "common.h" 3 3 4 #if !defined HAVE_GETOPT_LONG 5 # include "mygetopt.h" 6 #elif defined HAVE_GETOPT_H 7 # include <getopt.h> 8 #endif 9 10 #include <stdio.h> 11 #include <stdlib.h> 12 #include <string.h> 13 4 14 #include <pipi.h> 5 15 6 int main(void) 16 #if defined HAVE_GETOPT_LONG 17 # define mygetopt getopt_long 18 # define myoptind optind 19 # define myoptarg optarg 20 # define myoption option 21 #endif 22 23 #define MOREINFO "Try `%s --help' for more information.\n" 24 25 int main(int argc, char *argv[]) 7 26 { 8 pipi_image_t *i, *j; 27 char *srcname = NULL, *dstname = NULL; 28 pipi_image_t *src, *dst; 9 29 10 i = pipi_load("irc.png"); 11 j = pipi_resize(i, 180, 180); 12 pipi_save(j, "irc.bmp"); 13 pipi_free(i); 14 pipi_free(j); 30 int i, w = 0, h = 0; 31 32 for(;;) 33 { 34 int option_index = 0; 35 static struct myoption long_options[] = 36 { 37 { "geometry", 1, NULL, 'g' }, 38 }; 39 int c = mygetopt(argc, argv, "g:", long_options, &option_index); 40 41 if(c == -1) 42 break; 43 44 switch(c) 45 { 46 case 'g': 47 w = atoi(myoptarg); 48 if(strchr(myoptarg, 'x')) 49 h = atoi(strchr(myoptarg, 'x') + 1); 50 break; 51 default: 52 fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); 53 printf(MOREINFO, argv[0]); 54 return EXIT_FAILURE; 55 } 56 } 57 58 for(i = myoptind; i < argc; i++) 59 { 60 if(!srcname) 61 srcname = argv[i]; 62 else 63 dstname = argv[i]; 64 } 65 66 src = pipi_load(srcname); 67 dst = pipi_resize(src, w, h); 68 pipi_save(dst, dstname); 69 pipi_free(src); 70 pipi_free(dst); 15 71 16 72 return 0;
Note: See TracChangeset
for help on using the changeset viewer.