forked from tTh/FloatImg
		
	added universal exporter
This commit is contained in:
		
							parent
							
								
									9fda48ab30
								
							
						
					
					
						commit
						453d08aa23
					
				| @ -109,6 +109,10 @@ int fimg_colors_mixer_a(FloatImg *fimg, float fval); | ||||
| /*	#coronamaison			*/ | ||||
| int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused); | ||||
| 
 | ||||
| 
 | ||||
| /* universal exporter XXX */ | ||||
| int fimg_export_picture(FloatImg *pic, char *fname, int flags); | ||||
| 
 | ||||
| /*	PNM files module		*/ | ||||
| int fimg_save_as_pnm(FloatImg *head, char *fname, int flags); | ||||
| int fimg_load_from_pnm(char *fname, FloatImg *head, int notused); | ||||
|  | ||||
| @ -5,7 +5,7 @@ DEPS = ../floatimg.h Makefile | ||||
| OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o	\
 | ||||
| 	fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.o	\
 | ||||
| 	equalize.o fimg-fits.o saturation.o histogram.o		\
 | ||||
| 	hsv.o classif.o contour2x2.o qsortrgb.o | ||||
| 	hsv.o classif.o contour2x2.o qsortrgb.o exporter.o | ||||
| 
 | ||||
| #---------------------------------------------------------------
 | ||||
| 
 | ||||
| @ -67,6 +67,9 @@ classif.o:		classif.c $(DEPS) | ||||
| qsortrgb.o:		qsortrgb.c $(DEPS) | ||||
| 	gcc $(COPT) -c $< | ||||
| 
 | ||||
| exporter.o:		exporter.c $(DEPS) | ||||
| 	gcc $(COPT) -c $< | ||||
| 
 | ||||
| 
 | ||||
| hsv.o:		hsv.c $(DEPS) | ||||
| 	gcc $(COPT) -c $< | ||||
|  | ||||
							
								
								
									
										75
									
								
								funcs/exporter.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								funcs/exporter.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,75 @@ | ||||
| /*
 | ||||
|  *		exporter.c | ||||
|  */ | ||||
| 
 | ||||
| #include  <stdio.h> | ||||
| #include  <stdlib.h> | ||||
| #include  <string.h> | ||||
| 
 | ||||
| #include "../floatimg.h" | ||||
| 
 | ||||
| extern int		verbosity; | ||||
| 
 | ||||
| /* --------------------------------------------------------------------- */ | ||||
| /*
 | ||||
|  *	multi-magic 'save file' function. | ||||
|  */ | ||||
| int fimg_export_picture(FloatImg *pic, char *fname, int flags) | ||||
| { | ||||
| int		filetype; | ||||
| int		foo; | ||||
| 
 | ||||
| #if DEBUG_LEVEL | ||||
| fprintf(stderr, ">>> %s ( %p '%s' 0x%X )\n", __func__, | ||||
| 				pic, fname, flags); | ||||
| #endif | ||||
| 
 | ||||
| filetype = format_from_extension(fname); | ||||
| if (verbosity) { | ||||
| 	fprintf(stderr, "file %s : type %d\n", fname, filetype); | ||||
| 	} | ||||
| 
 | ||||
| switch(filetype) { | ||||
| 
 | ||||
| 	case FILE_TYPE_FIMG: | ||||
| 		foo = fimg_dump_to_file(pic, fname, 0); | ||||
| 		break; | ||||
| 
 | ||||
| 	case FILE_TYPE_PNM: | ||||
| 		foo = fimg_save_as_pnm(pic, fname, 0); | ||||
| 		break; | ||||
| 
 | ||||
| 	case FILE_TYPE_PNG: | ||||
| 		foo = fimg_save_as_png(pic, fname, 0); | ||||
| 		break; | ||||
| 
 | ||||
| 	case FILE_TYPE_TGA: | ||||
| 		fprintf(stderr, "%s: FILE_TYPE_TGA not implemented\n", | ||||
| 				__func__); | ||||
| 		foo = -666; | ||||
| 		break; | ||||
| 
 | ||||
| 	case FILE_TYPE_TIFF: | ||||
| 		foo = fimg_write_as_tiff(pic, fname, 0); | ||||
| 		break; | ||||
| 
 | ||||
| 	case FILE_TYPE_FITS: | ||||
| 		foo = fimg_save_R_as_fits(pic, fname, 0); | ||||
| 		break; | ||||
| 
 | ||||
| 	default: | ||||
| 		foo = -1789; | ||||
| 		break; | ||||
| 
 | ||||
| 	} | ||||
| 
 | ||||
| if (foo) { | ||||
| 	fprintf(stderr, "%s: exporting '%s' -> %d\n", __func__, | ||||
| 					fname, foo); | ||||
| 	/* que faire maintenant ? */ | ||||
| 	} | ||||
| 
 | ||||
| return foo; | ||||
| } | ||||
| /* --------------------------------------------------------------------- */ | ||||
| 
 | ||||
							
								
								
									
										32
									
								
								funcs/t.c
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								funcs/t.c
									
									
									
									
									
								
							| @ -45,7 +45,7 @@ if (foo) { | ||||
| 	return foo; | ||||
| 	} | ||||
| 
 | ||||
| foo = fimg_dump_to_file(&dst, "out.fimg", 0); | ||||
| foo = fimg_export_picture(&dst, "out.pnm", 0); | ||||
| if (foo) { | ||||
| 	fprintf(stderr, "%s : err %d saving result\n", __func__, foo); | ||||
| 	return foo; | ||||
| @ -58,6 +58,9 @@ return 0; | ||||
| /*
 | ||||
|  *	nouveau 5 octobre 2020 pendant sonoptic | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| int essai_contour_2x2(char *infile) | ||||
| { | ||||
| FloatImg	src, dst; | ||||
| @ -78,13 +81,13 @@ else	{ | ||||
| 
 | ||||
| fimg_clone(&src, &dst, 1); | ||||
| 
 | ||||
| foo = fimg_contour_2x2(&src, &dst, 1); | ||||
| foo = fimg_contour_2x2(&src, &dst, 0); | ||||
| if (foo) { | ||||
| 	fprintf(stderr, "%s: err %d in contour_2x2\n", __func__, foo); | ||||
| 	return foo; | ||||
| 	} | ||||
| 
 | ||||
| foo = fimg_save_as_pnm(&dst, "out.pnm", 0); | ||||
| foo = fimg_export_picture(&dst, "out2x2.pnm", 0); | ||||
| if (foo) { | ||||
| 	fprintf(stderr, "%s : err %d saving result\n", __func__, foo); | ||||
| 	return foo; | ||||
| @ -124,7 +127,7 @@ if (foo) { | ||||
| 	return foo; | ||||
| 	} | ||||
| 
 | ||||
| foo = fimg_save_as_pnm(&dst, "out.pnm", 0); | ||||
| foo = fimg_export_picture(&dst, "out.pnm", 0); | ||||
| if (foo) { | ||||
| 	fprintf(stderr, "%s : err %d saving result\n", __func__, foo); | ||||
| 	return foo; | ||||
| @ -222,8 +225,8 @@ fimg_save_as_png(&src, "test.png", 0); | ||||
| foo = fimg_rotate_90(&src, &dst, 0); | ||||
| fprintf(stderr, "rotate 90 -> %d\n", foo); | ||||
| 
 | ||||
| foo = fimg_save_as_png(&dst, "rotated90.png", 0); | ||||
| foo = fimg_save_as_pnm(&dst, "rotated90.pnm", 0); | ||||
| foo = fimg_export_picture(&dst, "rotated90.png", 0); | ||||
| foo = fimg_export_picture(&dst, "rotated90.pnm", 0); | ||||
| 
 | ||||
| fimg_destroy(&src); | ||||
| 
 | ||||
| @ -479,7 +482,7 @@ re = fimg_test_pattern(&fimg, 9, 1.0); | ||||
| if (re) { | ||||
| 	fprintf(stderr, "fimg_test_pattern -> %d\n", re); | ||||
| 	} | ||||
| fimg_save_as_pnm(&fimg, "mire.pnm", 0); | ||||
| fimg_export_picture(&fimg, "mire.pnm", 0); | ||||
| 
 | ||||
| return -1; | ||||
| } | ||||
| @ -525,7 +528,6 @@ return 0; | ||||
| } | ||||
| /* --------------------------------------------------------------------- */ | ||||
| 
 | ||||
| 		 | ||||
| int fimg_essai_histo(FloatImg *src, char *outpic, int k); /* histogram.c */ | ||||
| int fimg_essai_hsv(char *fname);				/* hsv.c */ | ||||
| 
 | ||||
| @ -598,7 +600,10 @@ void help(int k) | ||||
| { | ||||
| Command *pcmd; | ||||
| 
 | ||||
| fprintf(stderr, "usage:\n\t./t command filename\n"); | ||||
| fprintf(stderr, "usage:\n\t./t [options] command filename\n"); | ||||
| 
 | ||||
| fprintf(stderr, "options:\n"); | ||||
| fprintf(stderr, "\t-o  outfile\n"); | ||||
| 
 | ||||
| fprintf(stderr, "commands:\n"); | ||||
| pcmd = commands; | ||||
| @ -614,16 +619,19 @@ exit(0); | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
| int		foo, opt; | ||||
| char		*filename, *command; | ||||
| char		*filename, *command, *outfile; | ||||
| 
 | ||||
| fprintf(stderr, "++++++++ test des fonctions pid=%d\n", getpid()); | ||||
| 
 | ||||
| global_fvalue = 1.0; | ||||
| global_fvalue	= 1.0; | ||||
| outfile 	= "out.pnm"; | ||||
| 
 | ||||
| while ((opt = getopt(argc, argv, "hk:v")) != -1) { | ||||
| 
 | ||||
| while ((opt = getopt(argc, argv, "hk:p:v")) != -1) { | ||||
| 	switch(opt) { | ||||
| 		case 'h':	help(0);			break; | ||||
| 		case 'k':	global_fvalue = atof(optarg);	break; | ||||
| 		case 'o':	outfile = optarg;		break; | ||||
| 		case 'v':	verbosity++;			break; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user