two nice bw sweeepsss

This commit is contained in:
tonton Th 2020-01-03 15:39:11 +01:00
parent 46cd82f3b5
commit 360459d938
3 changed files with 88 additions and 3 deletions

View File

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

62
funcs/rampes.c Normal file
View File

@ -0,0 +1,62 @@
/*
* FLOATIMG
* rampes diverses, trucs etranges
*/
#include <stdio.h>
#include "../floatimg.h"
/* --------------------------------------------------------------------- */
int fimg_hdeg_a(FloatImg *img, double dcoef)
{
int x, y;
float value;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %f )\n", __func__, img, dcoef);
#endif
if (FIMG_TYPE_RGB != img->type) {
fprintf(stderr, "%s bad type\n", __func__);
return -6;
}
for (x=0; x<img->width; x++)
{
value = (float)x / (float)img->width;
value *= dcoef;
for (y=0; y<img->height; y++) {
fimg_plot_rgb(img, x, y, value, value, value);
}
}
return 0;
}
/* --------------------------------------------------------------------- */
int fimg_vdeg_a(FloatImg *img, double dcoef)
{
int x, y;
float value;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %f )\n", __func__, img, dcoef);
#endif
if (FIMG_TYPE_RGB != img->type) {
fprintf(stderr, "%s bad type\n", __func__);
return -6;
}
for (y=0; y<img->height; y++)
{
value = (float)y / (float)img->height;
value *= dcoef;
for (x=0; x<img->width; x++) {
fimg_plot_rgb(img, x, y, value, value, value);
}
}
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -48,6 +48,26 @@ printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.xyzzy");
printf("%-10s %d\n\n", fname, foo);
return 0;
}
/* --------------------------------------------------------------------- */
int essai_rampes(void)
{
FloatImg fimg;
int foo;
fimg_create(&fimg, 640, 480, FIMG_TYPE_RGB);
foo = fimg_hdeg_a(&fimg, (double)3.141592654);
fprintf(stderr, "make h deg -> %d\n", foo);
foo = fimg_save_as_pnm(&fimg, "hdeg.pnm", 0);
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
foo = fimg_vdeg_a(&fimg, (double)3.141592654);
fprintf(stderr, "make h deg -> %d\n", foo);
foo = fimg_save_as_pnm(&fimg, "vdeg.pnm", 0);
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
return 0;
}
/* --------------------------------------------------------------------- */
@ -81,7 +101,7 @@ int foo;
puts("++++++++++++++++++++++++++++++++");
foo = essai_ecrire_png("dessin.png");
foo = essai_rampes();
return 0;
}