forked from tTh/FloatImg
big commit for 2 new funcs
This commit is contained in:
@@ -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 sfx0.o
|
||||
fimg-libpnm.o rampes.o sfx0.o geometry.o
|
||||
|
||||
#---------------------------------------------------------------
|
||||
|
||||
@@ -30,6 +30,9 @@ misc-plots.o: misc-plots.c $(DEPS)
|
||||
filtrage.o: filtrage.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
geometry.o: geometry.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
sfx0.o: sfx0.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
|
||||
56
funcs/geometry.c
Normal file
56
funcs/geometry.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* FLOATIMG
|
||||
* distorsions géométriques - coredumping ?
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* really crude function, need more work...
|
||||
*/
|
||||
int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused)
|
||||
{
|
||||
int wd, hd;
|
||||
int foo, x, y;
|
||||
float pixel[3];
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
|
||||
src, dst, notused);
|
||||
#endif
|
||||
|
||||
/* no magic check here ? */
|
||||
if (dst->width || dst->height) {
|
||||
fprintf(stderr, "*** %s: image at %p not empty\n", __func__, dst);
|
||||
fimg_describe(dst, "destination halfsize");
|
||||
return -2;
|
||||
}
|
||||
|
||||
wd = src->width / 2; hd = src->height / 2;
|
||||
foo = fimg_create(dst, wd, hd, FIMG_TYPE_RGB);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err create %d\n", __func__, foo);
|
||||
return -3;
|
||||
}
|
||||
|
||||
for (y=0; y<hd; y++) {
|
||||
for (x=0; x<wd; x++) {
|
||||
foo = fimg_get_rgb(src, x*2, y*2, pixel);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err get %d\n", foo);
|
||||
abort();
|
||||
}
|
||||
foo = fimg_plot_rgb(dst, x, y, pixel[0], pixel[1], pixel[2]);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err plot %d\n", foo);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FLOATIMG
|
||||
* rampes diverses, trucs etranges
|
||||
* effets spéciaux àlc sur les couleurs
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
33
funcs/t.c
33
funcs/t.c
@@ -10,8 +10,37 @@
|
||||
|
||||
int verbosity;
|
||||
|
||||
int fimg_killcolors_a(FloatImg *fimg, float fval);
|
||||
/* --------------------------------------------------------------------- */
|
||||
int essai_geometrie(char *infile)
|
||||
{
|
||||
FloatImg fimg, result;
|
||||
int foo;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
foo = fimg_save_as_pnm(&fimg, "source.pnm", 0);
|
||||
|
||||
memset(&result, 0, sizeof(FloatImg));
|
||||
|
||||
foo = fimg_halfsize_0(&fimg, &result, 0);
|
||||
fprintf(stderr, "retour halfsize -> %d\n", foo);
|
||||
if (foo) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
fimg_describe(&result, "result after halfsize");
|
||||
|
||||
foo = fimg_save_as_pnm(&result, "something.pnm", 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int essai_sfx0(char *infile)
|
||||
{
|
||||
@@ -134,7 +163,7 @@ int foo;
|
||||
|
||||
puts("++++++++++++++++++++++++++++++++");
|
||||
|
||||
foo = essai_sfx0("03384.fimg");
|
||||
foo = essai_geometrie("foo.fimg");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user