61char *option[N_OPTIONS] =
73 "tiff2sdds <input> <output>\n"
74 " [-redOnly] [-greenOnly] [-blueOnly]\n"
75 " [-singleColumnMode]\n"
76 "Program by Robert Soliday. (" __DATE__
" " __TIME__
", SVN revision: " SVN_VERSION
")\n\n";
78int main(
int argc,
char *argv[]) {
82 char *input = NULL, *output = NULL;
83 char **column_names = NULL;
85 int32_t *indexes = NULL;
87 long i, j, n = 0, single_column_mode = 0;
91 rgb[0] = rgb[1] = rgb[2] = 1;
95 fprintf(stderr,
"%s", usage);
99 for (i = 1; i < argc; i++) {
100 if (s_arg[i].arg_type == OPTION) {
101 switch (
match_string(s_arg[i].list[0], option, N_OPTIONS, 0)) {
114 case OPT_SINGLECOLUMNMODE:
115 single_column_mode = 1;
118 fprintf(stderr,
"invalid option seen\n%s", usage);
123 input = s_arg[i].list[0];
125 output = s_arg[i].list[0];
127 fprintf(stderr,
"too many filenames\n%s", usage);
133 tif = TIFFOpen(input,
"r");
141 TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
142 TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
144 raster = (uint32_t *)_TIFFmalloc(npixels *
sizeof(uint32_t));
145 if (raster != NULL) {
146 if (TIFFReadRGBAImage(tif, w, h, raster, 0)) {
150 if (single_column_mode) {
153 fprintf(stderr,
"Problem defining parameter Variable1Name.\n");
157 fprintf(stderr,
"Problem defining parameter Variable2Name.\n");
162 fprintf(stderr,
"Problem defining parameter xInterval.\n");
166 fprintf(stderr,
"Problem defining parameter yInterval.\n");
171 fprintf(stderr,
"Problem defining parameter xDimension.\n");
176 fprintf(stderr,
"Problem defining parameter yDimension.\n");
181 fprintf(stderr,
"Problem defining parameter xMinimum.\n");
185 fprintf(stderr,
"Problem defining parameter yMinimum.\n");
189 fprintf(stderr,
"Problem defining column z.\n");
192 data = malloc(
sizeof(*data) * 1);
193 data[0] = malloc(
sizeof(*(data[0])) * npixels);
197 fprintf(stderr,
"Problem defining column Index.\n");
200 indexes = malloc(
sizeof(*indexes) * w);
201 column_names = malloc(
sizeof(
char **) * h);
202 data = malloc(
sizeof(*data) * h);
203 for (i = 0; i < h; i++) {
204 column_names[i] = malloc(
sizeof(
char *) * 15);
205 data[i] = malloc(
sizeof(*(data[i])) * w);
206 sprintf(column_names[i],
"Line%05ld", i);
208 fprintf(stderr,
"Problem defining column %s.\n", column_names[i]);
216 if (single_column_mode) {
219 for (i = 0; i < h; i++) {
220 for (j = 0; j < w; j++) {
222 data[0][j * h + i] = TIFFGetR(raster[n]) * rgb[0] + TIFFGetG(raster[n]) * rgb[1] + TIFFGetB(raster[n]) * rgb[2];
232 for (i = 0; i < w; i++)
234 for (i = 0; i < h; i++) {
235 for (j = 0; j < w; j++) {
237 data[i][j] = TIFFGetR(raster[n]) * rgb[0] + TIFFGetG(raster[n]) * rgb[1] + TIFFGetB(raster[n]) * rgb[2];
243 for (i = 0; i < h; i++) {
252 if (single_column_mode) {
256 for (i = 0; i < h; i++) {
257 free(column_names[i]);
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_StartPage(SDDS_DATASET *SDDS_dataset, int64_t expected_n_rows)
int32_t SDDS_SetColumnFromLongs(SDDS_DATASET *SDDS_dataset, int32_t mode, int32_t *data, int64_t rows,...)
Sets the values for a single data column using long integer numbers.
int32_t SDDS_DefineParameter1(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, void *fixed_value)
Defines a data parameter with a fixed numerical value.
int32_t SDDS_InitializeOutput(SDDS_DATASET *SDDS_dataset, int32_t data_mode, int32_t lines_per_row, const char *description, const char *contents, const char *filename)
Initializes the SDDS output dataset.
int32_t SDDS_DefineSimpleColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data column within the SDDS dataset.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
int32_t SDDS_DefineParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, char *fixed_value)
Defines a data parameter with a fixed string value.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
#define SDDS_STRING
Identifier for the string data type.
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
#define SDDS_DOUBLE
Identifier for the double data type.
long match_string(char *string, char **option, long n_options, long mode)
Matches a given string against an array of option strings based on specified modes.
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
void free_scanargs(SCANNED_ARG **scanned, int argc)