1 /* -*- c -*- */
2 
3 /*
4  * convert.c
5  *
6  * metapixel
7  *
8  * Copyright (C) 2003-2004 Mark Probst
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24 
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <assert.h>
29 
30 #include "getopt.h"
31 #include "lispreader.h"
32 
33 #include "metapixel.h"
34 
35 int
main(int argc,char * argv[])36 main (int argc, char *argv[])
37 {
38     int small_width = DEFAULT_WIDTH, small_height = DEFAULT_HEIGHT;
39 
40     while (1)
41     {
42 	static struct option long_options[] =
43             {
44 		{ "width", required_argument, 0, 'w' },
45 		{ "height", required_argument, 0, 'h' },
46 		{ 0, 0, 0, 0 }
47 	    };
48 
49 	int option, option_index;
50 
51 	option = getopt_long(argc, argv, "w:h:", long_options, &option_index);
52 
53 	if (option == -1)
54 	    break;
55 
56 	switch (option)
57 	{
58 	    case 'w' :
59 		small_width = atoi(optarg);
60 		break;
61 
62 	    case 'h' :
63 		small_height = atoi(optarg);
64 		break;
65 
66 	    default :
67 		assert(0);
68 	}
69     }
70 
71     printf("; -*- lisp -*-\n");
72 
73     do
74     {
75 	int i, channel;
76 	char filename[1024];
77 	lisp_object_t *obj;
78 	float means[NUM_CHANNELS];
79 
80 	scanf("%s", filename);
81 	if (feof(stdin))
82 	    break;
83 
84 	assert(strlen(filename) > 0);
85 
86 	printf("(small-image ");
87 
88 	obj = lisp_make_string(filename);
89 	lisp_dump(obj, stdout);
90 	lisp_free(obj);
91 
92 	printf(" (size %d %d) ", small_width, small_height);
93 
94 	for (channel = 0; channel < NUM_CHANNELS; ++channel)
95 	    scanf("%f", &means[channel]);
96 
97 	printf("(wavelet (means %f %f %f) (coeffs", means[0], means[1], means[2]);
98 
99 	for (i = 0; i < NUM_COEFFS; ++i)
100 	{
101 	    int index;
102 
103 	    scanf("%d", &index);
104 	    printf(" %d", index);
105 	}
106 
107 	printf(")) (subpixel");
108 
109 	for (channel = 0; channel < NUM_CHANNELS; ++channel)
110 	{
111 	    static char *channel_names[NUM_CHANNELS] = { "y", "i", "q" };
112 
113 	    printf(" (%s", channel_names[channel]);
114 
115 	    for (i = 0; i < NUM_SUBPIXELS; ++i)
116 	    {
117 		int val;
118 
119 		scanf("%d", &val);
120 		printf(" %d", val);
121 	    }
122 
123 	    printf(")");
124 	}
125 
126 	printf("))\n");
127     } while (!feof(stdin));
128 
129     return 0;
130 }
131