Compare commits

..

3 Commits

Author SHA1 Message Date
tonton Th
0224f6fd37 more expicit help 2020-01-03 18:21:43 +01:00
tonton Th
360459d938 two nice bw sweeepsss 2020-01-03 15:39:11 +01:00
tonton Th
46cd82f3b5 format string error 2020-01-03 15:30:47 +01:00
7 changed files with 115 additions and 11 deletions

View File

@ -2,7 +2,7 @@
* floatimg.h
*/
#define FIMG_VERSION 84
#define FIMG_VERSION 85
/*
* in memory descriptor
@ -91,6 +91,10 @@ int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
/* module funcs/rampes.c */
int fimg_hdeg_a(FloatImg *img, double dcoef);
int fimg_vdeg_a(FloatImg *img, double dcoef);
/* FIMG files module */
int fimg_fileinfos(char *fname, int *datas);
int fimg_dump_to_file(FloatImg *head, char *fname, int notused);

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 $<

View File

@ -13,7 +13,7 @@ int x, y, offset;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
fprintf(stderr," type %s size %dx%d\n", img->type,
fprintf(stderr," type %d size %dx%d\n", img->type,
img->width, img->height);
#endif

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;
}

View File

@ -55,7 +55,11 @@ static void help(int lvl)
{
Fx *fx;
puts("--- fimg special effects ---");
puts("------ fimg special effects ------");
puts("usage:");
puts("\tfimgfix [options] <effect> source.fimg resultat.fimg");
puts("effects:");
printf("\t");
for (fx=fx_list; fx->name; fx++) {
printf("%s ", fx->name);

View File

@ -12,6 +12,9 @@ int verbosity;
#define T_BLACK 1
#define T_DRAND48 2
#define T_GRAY 3
#define T_HDEG_A 4
#define T_VDEG_A 5
typedef struct {
int code;
char *name;
@ -21,7 +24,11 @@ Type types[] = {
{ T_BLACK, "black" },
{ T_DRAND48, "drand48" },
{ T_GRAY, "gray" },
{ T_GRAY, "grey" }
{ T_GRAY, "grey" },
{ T_HDEG_A, "hdeg" },
{ T_VDEG_A, "vdeg" },
{ 0, NULL }
};
static int get_type(char *name)
@ -35,7 +42,6 @@ fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name);
// #define TEST(str) ( ! strcmp(name, str) )
for (type = types; type->code; type++) {
// printf("\t%-15s %d\n", type->name, type->code);
if (!strcmp(name, type->name)) {
return type->code;
}
@ -46,13 +52,16 @@ return -1;
/* --------------------------------------------------------------------- */
static void help(int lj)
{
int foo;
puts("Usage:\tmkfimg [options] quux.fimg width height");
puts("\t-k N.N\tgive a float parameter");
puts("\t-t bla\t\thowto make the pic");
puts("\t\t\tblack, drand48...");
puts("\t-v\tincrease verbosity");
fputs("\t-t bla\thowto make the pic\n\t\t", stdout);
for (foo=0; types[foo].code; foo++) {
printf("%s ", types[foo].name);
}
puts("\n\t-v\tincrease verbosity");
if (verbosity) fimg_print_version(1);
@ -114,6 +123,8 @@ switch(type) {
case T_DRAND48: fimg_drand48(&fimg, fvalue); break;
case T_GRAY: fimg_rgb_constant(&fimg, fvalue, fvalue, fvalue);
break;
case T_HDEG_A: fimg_hdeg_a(&fimg, 1.0); break;
case T_VDEG_A: fimg_vdeg_a(&fimg, 1.0); break;
}
foo = fimg_dump_to_file(&fimg, fname, 0);