added fimg_killcolors_a effect

This commit is contained in:
Tonton Th 2020-02-07 18:01:28 +01:00
parent c48a3e4870
commit 622d011424
4 changed files with 71 additions and 4 deletions

View File

@ -2,7 +2,7 @@
* floatimg.h
*/
#define FIMG_VERSION 88
#define FIMG_VERSION 89
/*
* in memory descriptor
@ -75,6 +75,11 @@ int fimg_mul_3(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d);
/* 'sfx0' module */
int fimg_killcolors_a(FloatImg *fimg, float fval);
/* 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);

View File

@ -3,7 +3,7 @@
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
DEPS = ../floatimg.h Makefile
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
fimg-libpnm.o rampes.o
fimg-libpnm.o rampes.o sfx0.o
#---------------------------------------------------------------
@ -30,6 +30,9 @@ misc-plots.o: misc-plots.c $(DEPS)
filtrage.o: filtrage.c $(DEPS)
gcc $(COPT) -c $<
sfx0.o: sfx0.c $(DEPS)
gcc $(COPT) -c $<
rampes.o: rampes.c $(DEPS)
gcc $(COPT) -c $<

37
funcs/sfx0.c Normal file
View File

@ -0,0 +1,37 @@
/*
* FLOATIMG
* rampes diverses, trucs etranges
*/
#include <stdio.h>
#include "../floatimg.h"
/* --------------------------------------------------------------------- */
/*
* OMG ! a Color Graphic Adaptor emulator :)
*/
int fimg_killcolors_a(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->G[foo])
fimg->B[foo] = fimg->R[foo];
else
fimg->B[foo] = fimg->G[foo];
}
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -10,6 +10,25 @@
int verbosity;
int fimg_killcolors_a(FloatImg *fimg, float fval);
/* --------------------------------------------------------------------- */
int essai_sfx0(char *infile)
{
FloatImg fimg;
int foo;
fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
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.pnm", 0);
return 0;
}
/* --------------------------------------------------------------------- */
int essai_parse_double(void)
{
@ -44,7 +63,10 @@ char *fname;
foo = format_from_extension(fname="foo.fimg");
printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.pNm");
foo = format_from_extension(fname="foo.pnm");
printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.png");
printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.xyzzy");
@ -103,7 +125,7 @@ int foo;
puts("++++++++++++++++++++++++++++++++");
foo = essai_rampes();
foo = essai_sfx0(NULL);
return 0;
}