// API: open a fancy image struct fancy_image *fancy_image_open(char *filename, char *options) { // create return struct and its alias //struct fancy_image r[1]; struct fancy_image *r = xmalloc(sizeof*r); // I hate this malloc! struct FI *f = (void*)r; // process options parameter interpret_options(f, options); // if "c", do create the file if (f->option_creat) { if (filename_corresponds_to_tiffo(filename) || f->option_tw > 0) create_zero_tiff_file(filename, f->option_w, f->option_h, f->option_tw, f->option_th, f->option_spp, f->option_bps, f->option_fmt, true, f->option_compressed); else create_iio_file(filename, f->option_w, f->option_h, f->option_spp); } // read the image if (filename_corresponds_to_tiffo(filename)) { f->tiffo = true; tiff_octaves_init0(f->t, filename, f->megabytes,f->max_octaves); if (f->option_write) f->t->option_write = true; f->w = f->t->i->w; f->h = f->t->i->h; f->pd = f->t->i->spp; f->no = f->t->noctaves; } else { f->tiffo = false; f->x = iio_read_image_float_vec(filename, &f->w, &f->h, &f->pd); f->no = build_pyramid(f, f->max_octaves); strncpy(f->x_filename, filename, FILENAME_MAX); f->x_changed = false; } if (f->option_verbose) { fprintf(stderr, "FANCY IMAGE \"%s\"\n", filename); fprintf(stderr, "\tw = %d\n", f->w); fprintf(stderr, "\th = %d\n", f->h); fprintf(stderr, "\tpd = %d\n", f->pd); fprintf(stderr, "\tno = %d\n", f->no); fprintf(stderr, "\n"); fprintf(stderr, "\tmax_octaves= %d\n", f->max_octaves); fprintf(stderr, "\ttiffo = %d\n", f->tiffo); fprintf(stderr, "\tmegabytes = %g\n", f->megabytes); } // return image struct return r; }
void generic_create(struct FI *f, char *filename) { #ifdef FANCY_TIFF if (filename_corresponds_to_tiffo(filename) || f->option_tw > 0) create_zero_tiff_file(filename, f->option_w, f->option_h, f->option_tw, f->option_th, f->option_spp, f->option_bps, f->option_fmt, true, f->option_compressed); else #endif//FANCY_TIFF create_iio_file(filename, f->option_w, f->option_h, f->option_spp); }