added a second killcolors function
This commit is contained in:
		
							parent
							
								
									622d011424
								
							
						
					
					
						commit
						e761120787
					
				
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -5,7 +5,6 @@ lib/*.fimg
 | 
			
		||||
lib/*.png
 | 
			
		||||
lib/*.gif
 | 
			
		||||
 | 
			
		||||
funcs/*.o
 | 
			
		||||
 | 
			
		||||
*.a
 | 
			
		||||
gmon.out
 | 
			
		||||
@ -26,7 +25,9 @@ doc/*.ilg
 | 
			
		||||
doc/*.ind
 | 
			
		||||
 | 
			
		||||
funcs/t
 | 
			
		||||
funcs/*.o
 | 
			
		||||
funcs/*.png
 | 
			
		||||
funcs/*.gif
 | 
			
		||||
 | 
			
		||||
scripts/*.fimg
 | 
			
		||||
scripts/*.pnm
 | 
			
		||||
 | 
			
		||||
@ -78,6 +78,7 @@ int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d);
 | 
			
		||||
 | 
			
		||||
/*	'sfx0' module 			*/
 | 
			
		||||
int fimg_killcolors_a(FloatImg *fimg, float fval);
 | 
			
		||||
int fimg_killcolors_b(FloatImg *fimg, float fval);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*	PNM files module		*/
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										26
									
								
								funcs/sfx0.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								funcs/sfx0.c
									
									
									
									
									
								
							@ -22,15 +22,33 @@ if (FIMG_TYPE_RGB != fimg->type) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
nbpix = fimg->width * fimg->height;
 | 
			
		||||
 | 
			
		||||
for (foo=0; foo<nbpix; foo++) {
 | 
			
		||||
 | 
			
		||||
	if (fimg->R[foo] > fimg->G[foo])
 | 
			
		||||
		fimg->B[foo] = fimg->R[foo];
 | 
			
		||||
	else
 | 
			
		||||
		fimg->B[foo] = fimg->G[foo];
 | 
			
		||||
	
 | 
			
		||||
	}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
return 0;
 | 
			
		||||
}
 | 
			
		||||
/* --------------------------------------------------------------------- */
 | 
			
		||||
int fimg_killcolors_b(FloatImg *fimg, float fval)
 | 
			
		||||
{
 | 
			
		||||
int		nbpix, foo;
 | 
			
		||||
 | 
			
		||||
if (FIMG_TYPE_RGB != fimg->type) {
 | 
			
		||||
	fprintf(stderr, "%s: bad src type %d on %p\n", __func__,
 | 
			
		||||
					fimg->type, fimg);
 | 
			
		||||
	return -8;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
nbpix = fimg->width * fimg->height;
 | 
			
		||||
for (foo=0; foo<nbpix; foo++) {
 | 
			
		||||
	if (fimg->R[foo] > fimg->B[foo])
 | 
			
		||||
		fimg->G[foo] = fimg->R[foo];
 | 
			
		||||
	else
 | 
			
		||||
		fimg->G[foo] = fimg->B[foo];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								funcs/t.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								funcs/t.c
									
									
									
									
									
								
							@ -18,14 +18,23 @@ int essai_sfx0(char *infile)
 | 
			
		||||
FloatImg	fimg;
 | 
			
		||||
int		foo;
 | 
			
		||||
 | 
			
		||||
fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
 | 
			
		||||
if (NULL != infile) {
 | 
			
		||||
	fprintf(stderr, "loading %s\n", infile);
 | 
			
		||||
	fimg_create_from_dump(infile, &fimg);
 | 
			
		||||
	}
 | 
			
		||||
else	{
 | 
			
		||||
	fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
 | 
			
		||||
	fimg_draw_something(&fimg);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
fimg_draw_something(&fimg);
 | 
			
		||||
foo = fimg_save_as_pnm(&fimg, "something.pnm", 0);
 | 
			
		||||
 | 
			
		||||
foo = fimg_killcolors_a(&fimg, 0.0);
 | 
			
		||||
foo = fimg_save_as_pnm(&fimg, "colorskilled-a.pnm", 0);
 | 
			
		||||
 | 
			
		||||
foo = fimg_killcolors_b(&fimg, 0.0);
 | 
			
		||||
foo = fimg_save_as_pnm(&fimg, "colorskilled-b.pnm", 0);
 | 
			
		||||
 | 
			
		||||
foo = fimg_save_as_pnm(&fimg, "colorskilled.pnm", 0);
 | 
			
		||||
 | 
			
		||||
return 0;
 | 
			
		||||
}
 | 
			
		||||
@ -125,7 +134,7 @@ int		foo;
 | 
			
		||||
 | 
			
		||||
puts("++++++++++++++++++++++++++++++++");
 | 
			
		||||
 | 
			
		||||
foo = essai_sfx0(NULL);
 | 
			
		||||
foo = essai_sfx0("03384.fimg");
 | 
			
		||||
 | 
			
		||||
return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user